Reputation: 11
def printWord(a,b):
a= raw_input ("What would you like me to say?")
b= raw_input ("How many times would you like me to say it?")
int(float(b))
for i in range(b):
print a
this code keeps giving me this error:
line 10, in printWord
for i in range(b):
TypeError: range() integer end argument expected, got str.
Upvotes: 1
Views: 125
Reputation: 375504
You had the right idea with this line:
int(float(b))
but that doesn't change b in-place. You have to keep the result. Use this:
b = int(float(b))
Upvotes: 3
Reputation: 4448
Calling int(float(b))
does not change the state of b. After that line b is still a string, while range() expects an integer. I might change that line to b = int(b)
to modify b to what you need it to be.
Upvotes: 1