Quote:
Originally Posted by hunterjoz1996
Thanks for the resource. I got the if statement to work, the problem is the odd looping of 212. I don't understand why that happened, I guess python thought pay*50 meant loop it fifty times.
|
According to Python,
pay holds a string, so it's going to return the result of multiplying the string instead of the int type: "212" * 50 = "212212212...". You can try out something a little simpler with strings using the addition operator: "212" + "212" = '212212'.
If you want pay to be an int, you need to either reset the value of pay or use another variable to hold the new value. Here's my edit that resets the value of pay to an int type:
Code:
name = raw_input("Who are you?")
pay = raw_input("How much money do you get?")
pay = int(pay)
if pay > 200:
print "Your %s, and your pay is %s! Your cool!" % (name, pay)
print "%s: This is what you would have if you multiplied your pay by fifty." % (pay * 50)
You might want to check out the type() function, which will return the type of a python object, just in case you don't know, like this:
Code:
>>> my_money = raw_input("How much money? ")
How much money? 20
>>> type(my_money)
<type 'str'>
>>>