Python Forum
Returned value not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Returned value not defined
#1
I tried to create a random leveling system for mobs in my game, however, when I tried to check the output of a returned value It shows un in the console as "Undefined". Does anyone know why and how to solve it? I am sorry if the function seems complicated.

def monsterpower():
    import random
    weakmonsterlevel = random.randrange(1, 10, 1)
    normalmonsterlevel = random.randrange(5, 20 ,1)
    strongmonsterlevel = random.randrange(10, 40, 1)
    bosslevel = random.randrange(20, 80,1)
    weakmonsterhealth = weakmonsterlevel*1 +10
    normalmonsterhealth = normalmonsterlevel*1 +10
    strongmonsterhealth = strongmonsterlevel*1 +10
    bosshealth = bosslevel*2 + 20
    weakmonsterdamage = 2
    normalmonsterdamage = 4
    strongmonsterdamage = 6
    bossdamage = 10
    return weakmonsterhealth, normalmonsterhealth, strongmonsterhealth, bosshealth, weakmonsterdamage, normalmonsterdamage, strongmonsterdamage, bossdamage

print(weakmonsterhealth)
This is the error I got when I tried to print a returned value
NameError: name 'weakmonsterhealth' is not defined

oh I forgot to put this line in the paragraph, there is suppose to be
monsterpower()
before [python]print(weakmonsterhealth)[/p
Reply


Messages In This Thread
Returned value not defined - by somerandomguy123 - Jul-05-2019, 12:56 AM
RE: Returned value not defined - by ichabod801 - Jul-05-2019, 01:06 AM
RE: Returned value not defined - by perfringo - Jul-05-2019, 07:02 AM

Forum Jump:

User Panel Messages

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