Is it possible to input 2 numbers int
or float
separated by a comma in a single line?
Say after the program runs it would ask the user to <
num1,num2 = map(float, raw_input('Enter a range: ').split(','))
Alternatively, if you want to allow commas in the second value, use partition instead of split:
s1,_,s2 = raw_input('Enter a range: ').partition(',')
In this case, you'll have to convert the two strings to numbers by yourself.
num1, num2 = raw_input('Enter a range: ').split(',')
x,y = input("Enter range: ")
If you want them as numbers it's best not to use raw_input.
In python3 you can directly use input() method instead of raw_input()
var1,var2 = input().split(',')
It's my understanding that ast.literal_eval is safe:
>>> x, y = ast.literal_eval(raw_input('Enter a range: '))
Enter a range: 5, 6
>>> x, y
(5, 6)