

制作したPythonのプログラムで少しおかしすぎるエラーが発生しました。  
アーチェリー用のプログラムを制作しているのですが、動かそうとすると

[code]

    name 'MenberID' is not defined
    
[/code]

という少々おかしいエラーが出てきてしまいます。  
('MenberID' は変数ではなくリストとして定義したはずなんですけど...)

下のプログラムのコードでどこかおかしいところがあるならば教えてくれると幸いです。

[code]

    import datetime
    
    def set_up_players() :
        Assignment = True
        Memberlist = []
        MenberID = []
        while Assignment == True :
            print("")
            membership = str(input("Are you assigned already? Answer Y for 'Yes' N for 'No' :'"))
            if membership == "Y" :
                y1 = int(input("Enter your year to assign your membership. :"))
                m1 = int(input("Enter your month to assign your membership. :"))
                d1 = int(input("Enter your day to assign your membership. :"))
                dt1 = datetime.datetime(year=y1, month=m1, day=10, hour=d1)
                time = datetime.datetime.now() - dt1
                daytime = int((time.days))
                if daytime > 500 :
                    print("You need to renew your membership.")
                    print("Go to office to renew you membership card.")
                else :
                    print("Welcom back to our Archely club")
            elif membership == "N" :
                check = False
                print("You need to make your membership")
                name = str(input("Enter your name. :"))
                while check == False :
                    id = str(input("Enter any 5 digit number :"))
                    if (id in MenberID) == True:
                        print ("Sorry it's already in list, Try again.")
                    else :
                        check = True
                Memberlist.append(name)
                MenberID.append(id)
            else :
                print("Answer in Y or N.")
            print("")
            Assign = str(input("Finish assignment?? Answer Y for 'Yes' N for 'No' : "))
            if Assign == "N" :
                Assignment = True
            elif Assign == "Y" :
                Assignment = False
            else :
                print("Answer in Y or N.")
    
    
        return Memberlist,MenberID
    
    def sign_up_players() :
        Playerlist = []
        PlayerID = []
        player_count = 0
        while player_count == 5:
            id = str(input("Enter your  5 digit ID. :"))
            if (id in MenberID) == True:
                name = str(input("Enter your name. :"))
                Playerlist.append(name)
                PlayerID.append(id)
                player_count = player_count + 1
                print(player_count)
            else :
                print("Sorry but Register first.")
    
    
        return MenberID,Playerlist,PlayerID #エラーが出たのはここです
    
    def set_score(NoofPlayer) :
        score = []
        counter = NoofPlayer - 1
        for i in range (counter) :
            score.append(0)
        return NoofPlayer, score
    
    def set_values () :
        Memberlist,MenberID = set_up_players()
        MenberID,Playerlist,PlayerID = sign_up_players()
        NoofPlayer = int(len(Playerlist))
        maxshoot = 5
        set_score(NoofPlayer)
        Nooftargets = NoofPlayer
        NoofPG = NoofPlayer
        Round = 5
        Noofarrows = 1*Round*NoofPlayer
        NoofLays = NoofPlayer
        Podium = NoofPlayer
        return Memberlist,MenberID,Playerlist,PlayerID,NoofPlayer,maxshoot,Nooftargets,NoofPG,Round,Noofarrows,NoofLays,Podium
    
    def Allocate_Equipment(NoofPlayer) :
        ownarrows = []
        ownbows = []
        ownPG = []
        co = NoofPlayer
        while co > 0 :
            arrows = str(input("Do you have your own arrows? Answer Y for 'Yes' N for 'No' :'"))
            if arrows == "Y" :
                ownarrows.append(yes)
            else :
                ownarrows.append(no)
            PG = str(input("Do you have your own PG? Answer Y for 'Yes' N for 'No' :'"))
            if PG == "Y" :
                ownPG.append(yes)
            else :
                ownPG.append(no)
            bows = str(input("Do you have your own bow? Answer Y for 'Yes' N for 'No' :'"))
            if bows == "Y" :
                ownbows.append(yes)
            else :
                ownbows.append(no)
            co = co - 1
        print(ownarrows,ownPG,ownbows)
    
        return NoofPlayer, ownarrows, ownbows, ownPG
    
    def shooting_arrows (Playerlist,NoofPlayer,Round,score) :
        RoundTime = 0
        while Round > RoundTime :
            PlayerShoot = 0
            while PlayerShoot < Round :
                CurrentPlayer = 1
                while NoofPlayer > CurrentPlayer :
                    Player_shoot_arrow(Playerlist,CurrentPlayer)
                    Updata_score(score,CurrentPlayer,hitplace)
                    Displayscore(Playerlist,NoofPlayer,score)
                    CurrentPlayer = CurrentPlayer + 1
                PlayerShoot = PlayerShoot + 1
            RoundTime = RoundTime + 1
    
    
        return Playerlist,NoofPlayer,Round,score,RoundTime,PlayerShoot,CurrentPlayer
    
    def Player_shoot_arrow(Playerlist,CurrentPlayer) :
        print("It's "  , Playerlist[CurrentPlayer],  "'s turn.")
        hitplace = str(input("Where did you get? :"))
        return Playerlist,CurrentPlayer,hitplace
    
    def Updata_score(score,CurrentPlayer,hitplace) :
        if hitplace == "A":
            score[CurrentPlayer] = score[CurrentPlayer] + 100
        elif hitplace == "B":
            score[CurrentPlayer] = score[CurrentPlayer] + 50
        elif hitplace == "C":
            score[CurrentPlayer] = score[CurrentPlayer] + 10
    
    
        return score,CurrentPlayer,hitplace
    
    def Displayscore(Playerlist,NoofPlayer,score) :
        for i in range (NoofPlayer):
            print(Playerlist[NoofPlayer], + "'s score is " , + score[NoofPlayer])
    
        return Playerlist,NoofPlayer,score
    
    def score_board(Playerlist,NoofPlayer,Podium,score) :
        Displayscore(Playerlist,NoofPlayer,score)
        scorelist = []
        scorelist = score
        score.sort(reverse=True)
        Podium = len(score)
        third = score[2]
        second = score[1]
        first = score[0]
        print("Third Player is "  , Playerlist[scorelist.index(third)] ,  "who get " , scorelist[2])
        print("Third Player is "  , Playerlist[scorelist.index(second)] ,  "who get " , scorelist[1])
        print("Third Player is "  , Playerlist[scorelist.index(first)] ,  "who get " , scorelist[0])
        return Playerlist,NoofPlayer,Podium,score,scorelist
    
    
    Memberlist,MenberID,Playerlist,PlayerID,NoofPlayer,maxshoot,Nooftargets,NoofPG,Round,Noofarrows,NoofLays,Podium = set_values ()
    Allocate_Equipment(NoofPlayer)
    Playerlist,NoofPlayer,Round,score = shooting_arrows (Playerlist,NoofPlayer,Round,score)
    score_board(Playerlist,NoofPlayer,Podium,score)
    
[/code]


CC BY-SA 4.0
2019-12-19T08:31:09.850
61580
2020-01-03T16:30:58.973
2019-12-19T08:52:57.280
3060
36859
question
python python3
Pythonのプログラムで name 'MenberID' is not defined エラーになる


sign_up_players()関数において、MenberIdが未定義かと思います。

どこかに定義すると治ると思います。


CC BY-SA 4.0
2020-01-03T16:30:58.973
61950
2020-01-03T16:30:58.973
4041
61580
answer