Taking user inputs
Beginning Python Programming
Makzan, 2020 April.
Taking user inputs
- input code example
- trailing space in input prompt
- input result variables are always string
Code example: input
name = input("What is your name? ")
print("Hello " + name)
Code example: input
name = input("What is your name? ")
print("Hello " + name)
A space here
Running without trailing space
name = input("What is your name?")
print("Hello " + name)
> What is your name?Python
> Hello Python
Running with trailing space
name = input("What is your name? ")
print("Hello " + name)
> What is your name? Python
> Hello Python
Input variables are string
age = input("What is your age? ")
> What is your age? 32
> type(age)
<type 'str'>
Taking user inputs
- input code example
- trailing space in input prompt
- input result variables are always string