#๐Ÿ”’ need help with debug

35 messages ยท Page 1 of 1 (latest)

hearty rapids
#

e

fading mapleBOT
#

@hearty rapids

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.

hearty rapids
#

!paste

fading mapleBOT
#
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.

hearty rapids
#

this is a text based rpg game

#

I am having problems on line 54

#
Please press '1' to attack: 
Traceback (most recent call last):
  File "C:\Users\Hammad\PycharmProjects\pythonProject\RPGGAME(Remake).py", line 80, in <module>
    main(player, enemy)
  File "C:\Users\Hammad\PycharmProjects\pythonProject\RPGGAME(Remake).py", line 54, in main
    dragon_damage = enemy['special_two_en']['damage_three']
                    ~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'special_two_en'

the error

#

Please ping me if u want to help

cunning bloom
#

suggestion: ask something

hearty rapids
#

ask?

#

i asked for help

hearty rapids
velvet maple
hearty rapids
#

let me try

velvet maple
#

and after special_two there's an extra brace I think

hearty rapids
#
player = {
    1: {'name': player_name, 'hp': 100, 'damage': 10},
    2: {'name': player_name, 'hp': 100, 'damage': 12},
    3: {'name': player_name, 'hp': 125, 'damage': 15},
    4: {'name': player_name, 'hp': 130, 'damage': 20},
    5: {'name': player_name, 'hp': 150, 'damage': 25},
    6: {'name': last_player_name, 'hp': 15000, 'damage': random.randint(500, 600)},
    'special_pl':{'damage_two':random.randint(2000,4500),
    'special_two_pl':{'damage_three':random.randint(2500,3750)}}


}

enemy = {
    1: {'name': enemy_name, 'hp': 50, 'damage': 5},
    2: {'name': enemy_name, 'hp': 60, 'damage': 9},
    3: {'name': enemy_name, 'hp': 75, 'damage': 15},
    4: {'name': enemy_name, 'hp': 80, 'damage': 15},
    5: {'name': enemy_name, 'hp': 100, 'damage': 20},
    6: {'name': last_name_enemy, 'hp': 20000, 'damage': random.randint(150, 325)},
    'special_en':{'damage_two':random.randint(2500,5000),
    'special_two_en':{'damage_three':random.randint(1500,4000)}}

here?

velvet maple
#

yeah

hearty rapids
#
(2000,4500)}

this is the special_pl so like this?

#

at the last

velvet maple
#

yes

hearty rapids
velvet maple
#

I think there's an extra brace you need to remove after special_two_pl

#

and special_two_en too

hearty rapids
#

oh right

#

ty

cunning bloom
#

unrelated to the question, but I really want to comment on it:

            if attack_choice != '1' or attack_choice != 'GenocideCutter' or attack_choice != 'GalaxySlam':

that logic is wrong, and the reason the bug is there is that you have many NOT operations which humans can be bad at keeping track of. try to write your conditions to have at most one NOT operation in it and you'll find them much easier to get right

#

it's wrong because: in order to not satisfy that, it has to be simultaneously equal to all those different strings

hearty rapids
#

ok

#

i will close now

#

!close

fading mapleBOT
#
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.