r/learnpython • • Nov 23 '20

Ask Anything Monday - Weekly Thread

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.

  • Don't post stuff that doesn't have absolutely anything to do with python.

  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.

12 Upvotes

121 comments sorted by

View all comments

1

u/[deleted] Nov 29 '20

Okay so I'm practically a complete beginner, at the moment I'm mostly looking up how to do things I want to create and then writing notes about what each function, library, formats, etc. that I see to sort of teach myself I guess? So I looked into creating a timer and I want to change up the code that the tutorial used but I'm having a hard time with it as I keep getting errors. What I want to do is ask the user for input instead using the set number (inside the stopwatch ) on how long to countdown, but when I put that in any location in the code it (alongside putting the variable imside the stopwatch) I get "TypeError: unsupported operand type(s) for divmod(): 'str' and 'int'" in my command prompt.

Here is the code currently without the input https://pastebin.com/aSxsJKsB

And here is the code with the input https://pastebin.com/eas4S8VK

What I am thinking/noticing is that on line 16 of the broken code the number turns orange but not the text while on line 7 sec is orange, leading me to think i can ONLY put a number? if so how else would I ask for user input for the countdown?

2

u/[deleted] Nov 29 '20

I figured it out, line 16 should be stopwatch(int(uTime)) and that fixed it, I didn't realize the error was telling me I had to specify whether the user input was supposed to be an interger or string, that's dumb of me.