+ 2

How to take two inputs In python? My code is showing error

https://code.sololearn.com/cAE4HpNu941K/?ref=app

25th Aug 2022, 3:22 AM
|| H A C K E R Z 2 0 2 1 ||
|| H A C K E R Z 2 0 2 1 || - avatar
6 odpowiedzi
+ 4
You need to enter them on two lines, like this: lion 22
25th Aug 2022, 4:19 AM
lion
lion - avatar
+ 6
|| H A C K E R Z 2 0 2 1 || , as already mentioned from lion , the input in sololearn playground has to be done in 2 separate lines in the input window that pops up before the code is executed. to get spaces in the output between the arguments of the print() function, it is easier to use a comma ',' to separate them than using plus operator '+' for concatenation: print(name, "and", age)
25th Aug 2022, 6:07 AM
Lothar
Lothar - avatar
+ 1
Even better with f-string: print ( f ‘ {name} @ {age} ? ‘ ) (spaces added only for clarity)
25th Aug 2022, 8:56 AM
Monika
+ 1
Hold on, I told you slightly wrong thing: spaces WITHIN string are as you exactly want them - Python will ignore anything outside it. Sorry, just realised I wasn’t clear. Basically try to use f-string when you need some changeable values to be embedded within output, this way you’ll never have to concatenate or cast into str/int.
25th Aug 2022, 9:01 AM
Monika
0
have you tried to isolate the first part with brackets? print ((name+"and"),age)
25th Aug 2022, 4:28 AM
morl
morl - avatar
0
Monika Monika personally message kro
25th Aug 2022, 9:05 AM
|| H A C K E R Z 2 0 2 1 ||
|| H A C K E R Z 2 0 2 1 || - avatar