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()
2
  • It looks like it'll throw even more errors than that, your indentation is very wrong and python is white-space dependent. Please update your question with the correct spacing. Commented Dec 7, 2017 at 23:41
  • 1
    question edited. Commented Dec 7, 2017 at 23:46

2 Answers 2

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)
Sign up to request clarification or add additional context in comments.

1 Comment

python 2.x will evaluate the text entered, which could be dangerous.
2

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

varthree = int(varone) * int(vartwo)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.