why is the 'input' keyword taking only the first word? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why is the 'input' keyword taking only the first word?

s= input("enter something:") print(s) i gave the input as 'good morning' n the output i am getting is 'good'. the second word after space is not displayed.

13th Jul 2016, 6:53 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
16 Answers
+ 1
try the following code s = str(input("enter your word:")) print(s) you need to convert the input type as str inorder to print it as plain text
13th Jul 2016, 6:59 AM
sundar
sundar - avatar
0
m not using the quotes.
13th Jul 2016, 7:03 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
Sundar is correct
13th Jul 2016, 7:04 AM
isk
isk - avatar
0
while giving input itself we need to convert it's type as string it's good programming practice thanks @isk
13th Jul 2016, 7:07 AM
sundar
sundar - avatar
0
its not working sundar :/ whatever is written inside the double quotes is printed properly but while taking input from the user its taking only the first word.
13th Jul 2016, 7:11 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
That's weird? It's working for me.
13th Jul 2016, 7:15 AM
isk
isk - avatar
0
s = str(input("")) print(s) this was the code. when i run the program, it says user input required, so i typed good morning. but it outputs only good. the second word is not printed. y??
13th Jul 2016, 7:22 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
Priyanka can you show me the error it's throwing
13th Jul 2016, 7:23 AM
sundar
sundar - avatar
0
its not throwing any error. it is just not printing anything after the first word.
13th Jul 2016, 7:25 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
wats your python version
13th Jul 2016, 7:27 AM
sundar
sundar - avatar
0
3
13th Jul 2016, 7:28 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
The issue you are telling is weird. what's the ide you use. it's working fine with default python ide IDLE
13th Jul 2016, 8:25 AM
sundar
sundar - avatar
0
ya its working gud on IDLE but y not on the "code playground" of this app
13th Jul 2016, 11:16 AM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
Yes Priyanka you are right. coding playground and few other interactive fiddles are not giving the desired output in certain cases like this. It might be problem with the simulator.
13th Jul 2016, 11:34 AM
sundar
sundar - avatar
0
ok ty sundar! and i am pavithra not priyanka :p
13th Jul 2016, 1:47 PM
Pavithra Venkatesh
Pavithra Venkatesh - avatar
0
oops sorry typo and dictionary :-) :-p
13th Jul 2016, 1:49 PM
sundar
sundar - avatar