Найти - Пользователи
Полная версия: Функция с произвольным количеством параметров. Создание игры «Правда или действие»
Начало » Центр помощи » Функция с произвольным количеством параметров. Создание игры «Правда или действие»
1
Boomer
Задание 1
Измените игру «Правда или действие»: при некорректном выборе правды
или действия вместо наказания повторите вопросы.
Задание 2
Разработайте игру для получения ролей.
Когда пользователь вводит свое имя, ему случайным образом
должно быть присвоено имя супергероя. Количество пользователей
одновременно ограничивается только количеством супергероев. После
окончание работы выведите на экран имена игроков и соответствующих им персонажей.

кто сможет, прошу, я такой чайник что аааа….

вот какой код у меня есть:

 import random
listOfQuestion = []
listOfAction = []
listOfPlayer = []
def addPlayer(list):
    while True:
        name = input("Enter a Player name-")
        if len(name)<2:
            print("Please enter correct name!")
            continue
        list.append(str.capitalize(name))
        if len(list)>=2:
            needNextPlayer = input("More Player? - y/n ")
            if str.lower(needNextPlayer) == str.lower('y') or str.lower(needNextPlayer) == str.lower('yes'):
                continue
            else:
                break
def game(question, action, *args):
    for player in args:
        print(player)
        player_coise = input("Question or Action?")
        if player_choise == str.lower("q") or player_coise == str.lower("Question"):
            question_index = random.randint(0,len(question)-1)
            print(question[question_index])
            question.pop(question_index)
        elif player_choise == str.lower("a") or player_coise == str.lower("Action"):
            question_index = random.randint(0, len(question) - 1)
            print(action[question_index])
            question.pop(question_index)
        else:
            print("Do and answer")
            question_index = random.randint(0, len(question) - 1)
            print(question[question_index])
            question.pop(question_index)
            action_index = random.randint(0, len(action) - 1)
            print(action[action_index])
            question.pop(action_index)
addPlayer(listOfPlayer)
print(listOfPlayer)
xam1816
В player_coise не хватает буквы h

player_choise

исправьте в нескольких местах
  player_coise = input("Question or Action?")
        if player_choise == str.lower("q") or player_coise == str.lower("Question"):
            question_index = random.randint(0,len(question)-1)
            print(question[question_index])
            question.pop(question_index)
        elif player_choise == str.lower("a") or player_coise == str.lower("Action"):
helgaella99
Your Truth or Dare game project sounds interesting! To improve it, add handling of incorrect choices by repeating questions. Also, for the role-playing game, use random assignment of Build Now GG superheroes. Good luck with the code!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB