#๐ Only certain letters work
39 messages ยท Page 1 of 1 (latest)
@magic sinew
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.
what exactly isn't working here
I want to make a loop that prevents other characters from being typed in the input and only A, B, C can be typed
sorry i deleted the top message that explained it while trying to delete the image
!d any
any(iterable, /)```
Return `True` if any element of the *iterable* is true. If the iterable is empty, return `False`. Equivalent to...
have you learned about defining your own functions yet?
i havent heard of that yet
That's ok, Sacul has the right idea for it
Once you learn defining your own functions, this will be a great place to use it
ill keep an eye out for that in the future then if i see it in a video thank you
would i put this above line 31
or alongside
Have you used while before?
i have
It would go after getting input
so you get input, and then the while loop would reprompt them if they entered something invalid
another common way to do it is just assign guess a dummy value first
guess = ''
and then only rely on the while loop for input
alright thank you
is something like this alright?
i just went based off of a previous while true i used
I think it's overengineered. The message appears again anyways from the input
guess = ''
while guess not in ('A', 'B', 'C'):
guess = input("Enter (A, B, C): ").upper()
this is all it needs to be
i see
this looks a lot better thank you
This help channel has been closed. 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.