input(prompt)
returns (i.e.) has the value of what's entered with a keyboard input() returns a string. That means that if we want to read in an integer, we should use int(input(prompt))
.
Here are three variants of the same thing:
#Best style: human-readable, no excessive brevity.
my_input = input('Give me an integer: ')
print('Your input twice:', int(my_input)*2)
#Too many variables that aren't doing much: not as readable.
my_input_str = input('Give me an integer: ')
my_input_int = 2*int(my_input_str)
output_str = 'Your input twice:' + str(my_input_int)
print(output_str)
#Too brief, perhaps not as readable. The kind of thing that you would see if
#the programmer were trying to be clever
print('Your input twice:', int(input('Give me an integer: '))*2)