1

Can anyone tell me why my code is returning the error (in the Python IDLE)?:

TypeError: can't multiply sequence by non-int of type 'str' ".

here is the code that's been causing the errors:

def main():
    varone = input("Enter total number of episodes:  ")
    vartwo = input("enter approx. time of each episode (in minutes):  ")
    varthree = varone * vartwo
    print(varthree)
    print("minutes")
main()
SteveJ
  • 3,034
  • 2
  • 27
  • 47

2 Answers2

2

input() returns strings... Convert to integers:

varthree = int(varone) * int(vartwo)
Harvey
  • 5,703
  • 1
  • 32
  • 41
2

depends on whether you are using python 2.x or 3.x

in 3.x input always gives you a string, so a quick fix is:

varthree = int(varone) * int(vartwo)
ShpielMeister
  • 1,417
  • 10
  • 23