name = input('Enter your name: ')
if len(name) <= 3:
print ('Hi', name, ', you have a short name.')
else:
print('Hi', name, ', you have a long name.')
Asked
Active
Viewed 2,347 times
-6
-
2It looks like you already have a comma next to a variable. – 101 Jul 26 '18 at 06:21
-
1When i run it, this is my answer: Enter your name: ian Hi ian , you have a short name. and i want to move the comma back one space – St ian Jul 26 '18 at 06:22
-
Another option is to use the `sep` arg of `print`, eg `print('Hi ', name, ', you have a short name.', sep='')`. And in Python 3.6+ you can use an f-string to do the formatting: `print(f'Hi {name}, you have a short name.')`. – PM 2Ring Jul 26 '18 at 06:35
3 Answers
0
Why don't you use format?
print("Hi {}, you have a short name".format(name))

Sushant
- 3,499
- 3
- 17
- 34
-
-
-
-
1I didn't downvote, but it's always a risk when you answer questions that are fairly obvious duplicates... – PM 2Ring Jul 26 '18 at 06:52
0
You should try using the 'format' function:
print('Hey {name}, you have a nice name'.format(name=name))

john
- 11