#๐ Bug with appending strings to a list
10 messages ยท Page 1 of 1 (latest)
@hollow maple
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.
Basically if you try to use the spin() function with 5/6 unfired chambers left, it will be stuck in a forever while loop, and if you use the spin function with less than 5/6 unfired chambers left it will add one too many to make it have 7/6 if that makes sense
you are checking the value of chamber_count, right? well, it gets defined before the loop, and you never update the value after appending a new shot. since you're always checking the old value the loop can' t terminate.
a = 1
while a < 2:
...
# if you never change the value of a, it will loop forever.
# a += 1
Yeah it should be checking..?
chamber_count = len(shots)
while chamber_count != 6:
shots.append('dud')
try to follow the logic of your code. what happens to the value of chamber_count after shots.append('dud')?
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.