#πŸ”’ Need to repeat input multiple times before it gets registered

23 messages Β· Page 1 of 1 (latest)

carmine jettyBOT
#

@warm wedge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vivid pilot
#

You probably sent a file in your message, the bot doesn't like that :p

#

!paste read the embed for sharing your code

carmine jettyBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

warm wedge
#

yeah just saw that

#

will put it through the link its telling me

#

Basically, i'm having issues in my code near the end, where i promt the user to input r or q to either restart or quit the program. Restart works fine, but quit doesn't. I need to type q a few times before it quits, and i don't have much of a clue as how to fix this.

vivid pilot
#

Can you try using exit(0) instead of os._exit(0)? The latter is kinda weird and might be doing some unusual stuff

#

Nevermind that's not the problem

jagged phoenix
#

You are not saving the input, you are asking for an input 4 times in that last loop.

minor chasm
#

try something like clear_cmd = 'cls' if os.name == 'nt' else 'clear' btw. then you can just do os.system(clear_cmd)

jagged phoenix
#

So you will have to input something up to 4 times.

warm wedge
#

That fixed it

#

thank you

minor chasm
#

πŸ‘

#

If you want to check if someone entered the letter r or R you can either do if input_variable in 'rR': or if input_variable.casefold() == 'r':

#

!d str.casefold

carmine jettyBOT
#

str.casefold()```
Return a casefolded copy of the string. Casefolded strings may be used for caseless matching.

Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string. For example, the German lowercase letter `'ß'` is equivalent to `"ss"`. Since it is already lowercase, [`lower()`](https://docs.python.org/3/library/stdtypes.html#str.lower) would do nothing to `'ß'`; [`casefold()`](https://docs.python.org/3/library/stdtypes.html#str.casefold) converts it to `"ss"`.

The casefolding algorithm is [described in section 3.13 β€˜Default Case Folding’ of the Unicode Standard](https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf).

Added in version 3.3.
warm wedge
#

Thats good to know, will keep that in mind

#

Thank you all for the help

carmine jettyBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.