I want to ask subjects to type in first a float number ( like 3.666) followed by an integer. what i did is:
x,y = input ( " Please enter two numbers"). split ()
and then converted
x,y =[ float (x), int (y)]
It does not work-are there any suggestions?
You have to scan them as a string, separate it by space as delimiter and then typecast them to their corresponding types.
s = raw_input("Please enter two numbers: ")
x,y = s.split(" ")
x = float(x)
y = int(y)
Hope that helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.