I am not sure why I am getting this error. I have read and tried different things, but it is not working.
def product():
y, x= raw_input('Please enter two numbers: ')
times = float(x) * int(y)
print 'product is', times
product()
What am I doing wrong? Thank you so much
raw_inputreturns a single string. to unpack arguments as you’re doing, it would need to return 2 things.You could do something like this:
Note that this is still a little fragile because the user could input a string like “2 1 3”. The unpacking would work without an exception, but it would choke when trying to convert “1 3” to an integer. The most robust way to do these things is via a
try/exceptblock. Here’s how I would do it.