Strange input problem! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson

Strange input problem!

If I try the input "print("any string")" , the output comes out something like this: any string You entered: print("any string") result: None # why does this happen? # here is the code:

5th Nov 2019, 3:37 AM
Ishmam - avatar
4 Answers
+ 3
eval converts strings into executable Python code. print is a function that returns None, because it's return wouldn't have big value. print(print("any string")) would print: any string None Because print("any string") evaluates to None
5th Nov 2019, 7:05 AM
Seb TheS
Seb TheS - avatar
+ 1
Oh, I see! Thanks Seb TheS for the brief explanation. 😄😄😄
5th Nov 2019, 3:08 PM
Ishmam - avatar
wet water ))) I think it's the magic of the function "eval() ". Please check out the code correctly. I just want the explanation of this code.
5th Nov 2019, 4:08 AM
Ishmam - avatar
Why are not using input method or function it is easy or u will be not confuse by it For example: a=input("any string:") Print(a) Thank you best of luck
5th Nov 2019, 4:35 AM
vikrant soni
vikrant soni - avatar