Python Forum
Unable to unpack at line 184
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to unpack at line 184
#3
    def choose_enemy_spell(self):
        magic_choice = random.randrange(0, len(self.magic))
        spell = self.magic[magic_choice]
        magic_dmg = spell.generate_damage()

        pct = self.hp / self.maxhp * 100

        if self.mp < spell.cost or spell.type == "white" and pct > 50:
            self.choose_enemy_spell()
        else:
            return spell, magic_dmg
In one case you return nothing, in the other case you return (spell, magic_dmg). It is the first case that will give you the error.
Nitil likes this post
Reply


Messages In This Thread
Unable to unpack at line 184 - by Nitil - Apr-27-2021, 06:34 PM
RE: Unable to unpack at line 184 - by Axel_Erfurt - Apr-27-2021, 07:05 PM
RE: Unable to unpack at line 184 - by ibreeden - Apr-28-2021, 07:28 AM
RE: Unable to unpack at line 184 - by popejose - Apr-28-2021, 02:59 PM
RE: Unable to unpack at line 184 - by Nitil - May-01-2021, 02:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python code unable to show Bokeh line chart kirito85 2 2,615 Feb-06-2019, 07:52 AM
Last Post: kirito85

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020