#๐ i am new in python here is my code rate it 1-10
29 messages ยท Page 1 of 1 (latest)
@willow wraith
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.
Recommend: Don't hardcode stuff
i.e. you should able to add a weapon/slot... Without changing the main code but just the constant variable
while player_pick_up_item:
. . .
player_pick_up_item = False
This will never loop since you're unconditionally setting the flag to false at the end.
!e
x = True
while x:
print('Looped')
x = False
@brittle gate :white_check_mark: Your 3.12 eval job has completed with return code 0.
Looped
It should have just be an if
It don't seem to require to run more than once
At least for now
Maybe an if, although player_pick_up_item is always True before then, so it seems like there shouldn't be a while or if at all.
Unless it will become more complicated later, and player_pick_up_item may be false in the future.
Well, it said it want a flag to control, so may as well just leave it there
yeah i tried to think of way but, the only way i found worked was creating a different variable for each slot. thats why there is a bunch of if statements. because each slot should have its own choice or unique value set by the user
either 1 or 2
Use list?
what about the if else if statements, for each new slot right i want there to be a choice between 1 or 2. How would we implement this without creating a bunch of if else if statements and using a shorter method
Make the slots a list, then loop to populate the list. Any time you start adding numbers to variable names, you almost certainly want a list instead.
Defining a bunch of separate variables will make this much harder.
Something like:
slots = []
for n in range(5):
choice = int(input(f"Enter 1 for SMG, 2 for Shotgun for slot {n + 1}: "))
slots.append(options_item[choice - 1])
You'd maybe want to add some error handling in case the user enters something dumb, but that loop replaces all of the ifs at the top.
@willow wraith I rate it 2/10
is that not too low
why is it only 2 out of 10
Well it's too short to judge more detailed. Buts what's there isn't very good
thanks for your feedback
Keep in mind that asking for a rating from 1-10 isn't productive. No, this code is not very good, but I saw significantly worse when I was in school. It's Ok for an early beginner, bad for someone who is experienced.
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.