I searched for other answers but couldn't get it right. It'd be awesome if someone could help me :) I keep getting this error: TypeError: can only concatenate str (not "NoneType") to str | on this code. I was trying to write a code that makes automatic e-mail based on the name of the person plus the ammount of characters in their name.
name = input("whats your name?")
number_of_letters = len(name "gmail.com")
print(len(name))
print((name) (len(name)) ("@gmail.com"))
CodePudding user response:
You can't add int and str,
You just need to change this line,
print((name) str(len(name)) ("@gmail.com"))
# ^ edited here
CodePudding user response:
len(name) returns an int value, so when you do name len(name), Python doesn't know if it should be adding the values or concatenating them. You can use str(len(name)) to make it clear that you want len(name) to be treated as a string. Also, the parentheses around each piece aren't necessary (although they won't cause any problems either).
print(name str(len(name)) "@gmail.com")
