Hey all, I was tasked to create a game for homework but I still can't seem to figure out how to assign each individual player a "Score" variable that changes as the game progresses. E.g.
If user inputs that there are 3 players, later in which the 3 players' names are appended into a list, how would I assign each player a individual variable in which it contains their respective scores?
If user inputs that there are 3 players, later in which the 3 players' names are appended into a list, how would I assign each player a individual variable in which it contains their respective scores?
import random
count = 0
playerList = []
def rollTurn():
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
print("Your first dice rolled a: {}".format(dice1))
print("Your second dice rolled a: {}".format(dice2))
print("-------------------------MAIN MENU-------------------------")
print("1. Play a game \n2. See the Rules \n3. Exit")
print("-------------------------MAIN MENU-------------------------")
userAsk = int(input("Enter number of choice"))
if userAsk == 1:
userNun=int(input("Number of players?\n> "))
while len(playerList) != userNun:
userNames=input("Please input name of player number {}/{}\n> ".format(len(playerList)+1, userNun))
playerList.append(userNames)
random.shuffle(playerList)
print("Randomizing list..:",playerList)
print("It's your turn:" , random.choice(playerList))
rollTurn()
while count < 900000:
rollAgain=input("Would you like to roll again?")
if rollAgain == "Yes":
count = count + 1
rollTurn()
elif rollAgain == "No":
print("You decided to skip")
breakThis is what I currently have that pertains to this specific task. So what should I add so that each player/element in playerList is given a variable that contains their respective scores? Also(Sorry for asking multiple questions), as this game is round based, as I'm randomizing the order in which the players play, how would I that after each player is done, it picks the player directly after the current player, in other words, how would I pick the element directly after? I know there's a function for that but I can't seem to remember... Thanks for entertaining my ignorance and any help would be much appreciated, thanks :)
