Input function, do not understand the error message | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Input function, do not understand the error message

Hi I am writing name=input("enter name: ") print("you entered:" +name, " ", sep=" ", end="!") What I expected is that the user is prompted to enter a name, say Sally, then on the consul will appear" you entered:Sally! But instead I get the message 3 times. i.e. you entered:Sally !you entered:Sally !you entered:Sally ! Can anyone tell me why? And why it's repeating 3 times?

14th Apr 2019, 10:49 AM
Josie The Ritalin Dog
Josie The Ritalin Dog - avatar
7 Answers
+ 7
hi if i use your code snippet and run in SoloLearn Code Playground i get the result: enter name: you entered:Sally ! This all in 1 line. Can you post your code in sololearn and share it here? Would be helpful. Beside of this, you do not need to use the options argument from print() in this case. Your code: print("you entered:" +name, " ", sep=" ", end="!") can be done this way: print("You entered: " + name + "!") or just: print('You entered: ', name, '!')
14th Apr 2019, 11:05 AM
Lothar
Lothar - avatar
+ 4
If the output came three times although you expected one, there clearly has to be a mistake somewhere. If you post your code, we can help you find it!
14th Apr 2019, 11:19 AM
HonFu
HonFu - avatar
+ 4
I am sure your code is OK.
14th Apr 2019, 11:19 AM
Lothar
Lothar - avatar
+ 3
Ariella, what could have happend is that you run your code in your system and it outputs it correctly. If you run your code again, the console will not be cleared and so you have the output twice. Run it again and you have it 3 times. can you check this?
14th Apr 2019, 11:51 AM
Lothar
Lothar - avatar
+ 2
I think it has to do with the ," " part...I would replace the , with a + then it should work. Unfortunately I can't explain this behaviour
14th Apr 2019, 11:07 AM
Marcin Szcz
Marcin Szcz - avatar
+ 2
Hi! I posted my code above...
14th Apr 2019, 11:29 AM
Josie The Ritalin Dog
Josie The Ritalin Dog - avatar
+ 1
Thanks all. I was writing in another place, not solo playrground. I think it's a local issue and the code was ok, at least that's what I am hoping.
14th Apr 2019, 11:13 AM
Josie The Ritalin Dog
Josie The Ritalin Dog - avatar