0

How come sololearn keeps outputting the value of the fname and lname variables even though I haven't asked for it ?

fname = input("John") lname = input('Anderson') #your code goes here name = "Kin" print(fname[0] + '.' + lname[0] + '.') It'll keep printing JohhAndersonJ.A

25th Sep 2021, 9:28 AM
Kinsley
Kinsley - avatar
8 Answers
+ 5
Kinsley Cause if you write sth inside of "input()" it displays on the screen and when you enter an example, if you print the entered example, it also displays. So the problem this is. I hope, it's clear. For example: x = input("number:") #you enter 5 as input print(x) output becomes number:5
25th Sep 2021, 9:44 AM
mesarthim
mesarthim - avatar
+ 2
Okay I get it now thanks
25th Sep 2021, 9:46 AM
Kinsley
Kinsley - avatar
+ 2
I see
25th Sep 2021, 9:51 AM
Kinsley
Kinsley - avatar
+ 1
The printing code line must be, print(fname+lname+fname[0]+'.'+lname[0]) Try and see! I hope, it helps. Happy coding!
25th Sep 2021, 9:31 AM
mesarthim
mesarthim - avatar
+ 1
Kinsley Whole code must be, fname = input() lname = input() #your code goes here print(fname+lname+fname[0]+'.'+lname[0])
25th Sep 2021, 9:38 AM
mesarthim
mesarthim - avatar
+ 1
Kinsley Look at my code and enter the inputs orderly and breaking a new line, then submit. Like: John Anderson Submit https://code.sololearn.com/cAM3QLdaHHJ1/?ref=app
25th Sep 2021, 9:48 AM
mesarthim
mesarthim - avatar
0
Well thanks for helping mesarthim but it outputs JohnAndersonJohnAndersonJohnAndersonJ.A
25th Sep 2021, 9:34 AM
Kinsley
Kinsley - avatar
0
mesarthim JohnAndersonJohnAndersonJ.A
25th Sep 2021, 9:40 AM
Kinsley
Kinsley - avatar