+ 1
word=input('Enter a word');Enter a word:cheese;print(word+'shop') why space comes in between cheese nd shop
6 ответов
+ 7
Space doesnt come in b/w cheese and shop unless you enter 'cheese ' as the input.
+ 4
Cheese Shop
+ 3
If you want to make sure that there is no white space before or after the word that is entered you can use the str.strip() method.
print(word.strip() + 'shop')
You could also use it chained to the input function, since it returns a string.
word=input('Enter a word').strip()
There is also a left strip which only removes white space on the left of the string, and right strip which removes white space on the right of the string.
lstrip()
rstrip()
+ 1
Ans cheee shop
+ 1
cheese shop
0
I got struggled in that too. It has nothing to do with input, they made a trick. It was written print(word + ' shop'), if you look carefully, you will notice the space BEFORE shop