+ 1
inlining/combining print and input
Could I inline/shorten print and user input? For example: Print(input("Enter your name: ") Would this error? Or prompt input and print?
1 Answer
+ 5
Yes this is fine.
Remember all the input() function does is RETURN the users input as a string.
Also, writing input() will call the function.
So:
a = input()
This is assigning a to the return value of the function called input. Which will be whatever the user inputs to the console.
So:
print(input())
Would just be printing whatever is returned from the input() function.
Aka: print whatever the user enters.
Great Questionâ