Python provides a method called input
, which
will prompt the user and read in input, which it will pass on as a string:
myString = input("What is your string")
It will print the prompt, read in the value and it will assume that it is a
string, not matter whati you enter. If you wish to enter integer input, you
need to convert it to the integer data type by using the int
method:
value1 = int(input("What is the first value?"))
If you wish to enter float input, you need to convert it to the float data
type by using the float
method:
value2 = float(input("What is the second value?"))