Print ('enter a no. ') and input ('enter a no. '), both are giving same out put, does that mean I can use either of them? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Print ('enter a no. ') and input ('enter a no. '), both are giving same out put, does that mean I can use either of them?

24th Jan 2018, 2:03 AM
Deadpool
4 Answers
+ 12
print ('something') ---> is used to print something between quotes... while input('something') ---> will be used to take input from user... it will also print something & input provided by user on screen... so if u want 2 take input from user & print it on screen use input()
24th Jan 2018, 2:21 AM
🌛DT🌜
🌛DT🌜 - avatar
+ 6
Yes you can..
24th Jan 2018, 2:04 AM
Jaydeep Khatri
Jaydeep Khatri - avatar
0
Can there be a situation where only one of them will give the desired result n not the other one?
24th Jan 2018, 2:06 AM
Deadpool
0
If your intention is for the user to enter a number, or any input at all, then the best practice is to use input(). If you use a print() you will need to accompany it with an input() anyway, so your code would be not only inefficient but it would be a bad practice. Regarding your question "Can there be a situation where only one of them will give the desired result n not the other one?": Yes, using print() + input() will add a new line after your text, but using only input() will not.
24th Jan 2018, 4:51 AM
William Coronado
William Coronado - avatar