Hello all,

   I am working on trying to understand classes by creating a
character generator for a rpg. I know I am doing something silly but I
am not sure what. When I run the program I and type no when prompted I
get the following message:
Traceback (most recent call last):
  File "/Users/ara/Documents/ct_generator.py", line 10, in <module>
    class Main:
  File "/Users/ara/Documents/ct_generator.py", line 68, in Main
    reroll()
  File "/Users/ara/Documents/ct_generator.py", line 53, in reroll
    upp()
NameError: global name 'upp' is not defined

I guess it doesn't recognize that I want to call the function upp()
again. I think I might be using the wrong syntax here. My code is
below. Thank you any help or guidance.

Ara

###################################################################################
#Version: not even 0.1
#By: Ara Kooser
#
####################################################################################

import random


class Main:



    print """Welcome to the Classic Traveller character generator.
Written in Python"""
    print """Press return to generate a character"""

    raw_input()



    def upp():
        print """Generating your UPP."""
        print

        strength = 0
        dexterity = 0
        endurance = 0
        intelligence = 0
        education = 0
        social = 0

        strength = random.randrange(2,12)
        dexterity = random.randrange(2,12)
        endurance = random.randrange(2,12)
        intelligence = random.randrange(2,12)
        education = random.randrange(2,12)
        social = random.randrange(2,12)

        return strength, dexterity, endurance, intelligence, education, social


    print upp()

    def reroll():

        a = raw_input("Are you satisfied with your UPP? Choose yes or
no.").lower()
        try:

            if a == "yes":
                career()

            elif a == "no":
                upp()

            else:
                print "Please choose a valid option."
                print
                reroll()

        except ValueError:
            print "Please choose a valid option."
            print
            reroll()

        return

    print """You have a chance to reroll if needed."""
    reroll()

    def career():
        print """You will now choose are career path for your character."""













-- 
Quis hic locus, quae regio, quae mundi plaga. Ubi sum. Sub ortu solis
an sub cardine glacialis ursae.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to