3
u/MrPhungx Aug 20 '21
So the error occurs because you can't do something like print("my String" + 5) because 5 needs to be converted to String first. You won't get the error when you do:
print("one for " + str(name) + " one for me")That's not your Main Problem though. Your check if the string is a number is wrong. You need to do
if x.isnumeric():
# do something with your number2
u/robohobo- Aug 21 '21
As mentioned earlier use isdigit() to check if input is an int.
You're using x and name interchangeably just take out x altogether and put name as function parameter
I prefer f strings for formatting Print(f"name is {name}....")
3
u/northernbloke Aug 20 '21
Hi, Couple of things I see wrong
to test if a variable contains a INT you can use isdigit()
You are trying to Add an INT to the string in your else statement. You could change it to + str(name) +
Also, are you trying to test for Strings on your Elif or an Empty Variable?
However, I am but a noob at python myself and I may be completely wrong.