So there's not much necessarily wrong with my code but I wanted an expert opinion on it because im new and quite proud. I couldn't copy it but here's a link: https://trinket.io/python/988c8be55ac1
#๐ New to python
15 messages ยท Page 1 of 1 (latest)
@hazy sequoia
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.
Closes after a period of inactivity, or when you send !close.
You're using Python 2, which has been deprecated for a while
Any reason why you're using Trinket ?
Its finished homework and they make us use that.
Sorry for not replying quickly
instead of using codeABCDbool for the while loop, you could use attemptsRemaining to check if you have to loop again
if codeAbool and codeBbool and codeCbool and codeDbool == True:
this code will work, but probably doesn't do what you think it does. those elements of the if statement are individually resolved as essentially:
if (codeAbool) and (codeBbool) and (codeCbool) and (codeDbool == True):
This still works because a bool on its own is checked if it's true or not in if statements, but what i think you expected this to do is equate true to every individual elements. if you want to do that in the future, you'll have to check each individually or use a loop to check if they are all true
I'm not sure if comprehensions are in py2, but in py3 you can do
all(code == True for code in (codeAbool, codeBbool, codeCbool, codeDbool)
which will check if all of them equal True (which, == True is still unnecessary, you could do code aswell in this case)
correct me if I'm wrong, but I dont see you use codeList anywhere
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.