+ 5

Output error

name1 = input("Enter 1st name: ") name2 = input("Enter last name: ") print("Hey! whats up!"+ name1 + " " + name2) The output should be( Hey! Whats up! Name1 name2) But where is the problem?

24th Oct 2022, 6:59 AM
Mustakim Rahman
Mustakim Rahman - avatar
22 odpowiedzi
+ 5
Developers should solve this so that app user can be benefited by using sololearn platform.
25th Oct 2022, 12:29 PM
Mustakim Rahman
Mustakim Rahman - avatar
+ 3
Mustakim Rahman I run your code..it runs..it didn't show name error ...give name 1 and then press enter and give name 2 then click submit button...try like this
25th Oct 2022, 6:56 AM
Riya
Riya - avatar
+ 3
It should be like this name1 = input() name2 = input() print (" Hey! what\'s up!" + name1 + name2) but there is a catch you have to add space at last of name1 please do something with this code mentors and help me with this too
25th Oct 2022, 9:08 AM
Saswat Sahu 8432
Saswat Sahu 8432 - avatar
+ 3
Jony It may not work because of [ ' ] in what[ ' ]s up because it will not be excluded and will be treated as element,tag,whatever. To exclude it you have to use[ \ ] this sign like mine You can try it in code playground you can try
25th Oct 2022, 2:27 PM
Saswat Sahu 8432
Saswat Sahu 8432 - avatar
+ 2
Mustakim Rahman give name1 and name2 in new line before clicking submit...it won't show EOF error..
24th Oct 2022, 8:18 AM
Riya
Riya - avatar
+ 2
Mis riya after adding name 1&2 it shows name error And after using f string it showing invalid syntax
25th Oct 2022, 1:57 AM
Mustakim Rahman
Mustakim Rahman - avatar
+ 1
I think it’s a bug. However thanks a lot for helping.
24th Oct 2022, 7:11 AM
Mustakim Rahman
Mustakim Rahman - avatar
+ 1
Use f-string. 👇 name1 = input("Enter 1st name: ") name2 = input("Enter last name: ") print(f"Hey! What\'s up, {name1} {name2}") Just try it 👆, you'll understand
24th Oct 2022, 8:47 PM
Илья
+ 1
Maybe try: name1 = (input("")) name2 = (input("")) print ("Hey whats up!" + " " + name1 + " " +name2 )
25th Oct 2022, 3:50 AM
Megan J
Megan J - avatar
+ 1
I think the second added empty string " " space before name1 fixes it.
25th Oct 2022, 3:54 AM
Megan J
Megan J - avatar
+ 1
Write in a new line While giving input for last name
25th Oct 2022, 4:43 AM
Krishna
Krishna - avatar
+ 1
It doesn't show any problem, you try it on online compiler
25th Oct 2022, 8:25 AM
Darshan Badgujar
0
But it is showing some error in name2 line
24th Oct 2022, 7:02 AM
Mustakim Rahman
Mustakim Rahman - avatar
0
EOF error brother
24th Oct 2022, 7:06 AM
Mustakim Rahman
Mustakim Rahman - avatar
0
Try this: print("Enter 1st name: ") name1 = input() print("Enter last name: ") name2 = input() print("Hey! what's up!" + name1 + " " + name2)
25th Oct 2022, 1:56 PM
Jony
Jony - avatar
0
Hey
26th Oct 2022, 3:08 AM
Prince
Prince - avatar
0
Output error name1 = input("Enter 1st name: ") name2 = input("Enter last name: ") print("Hey! whats up! ", name1 , " " , name2)
26th Oct 2022, 6:20 AM
the juggler
the juggler - avatar