game = 'ON' while game == 'ON': start_game() # тут запуск твоей игры game = input('Повторить введите - ON')
while True: game = input("вокруг или около?") if game == "вокруг": print("выход") break elif game == "около": print("код моей игры") else: print("?!")
RomissevdЕсть способ легче? Просто снова пробелы ставить не очень охота. Если это поможет. вот код :
start_game(
import random
print("------------------------------------")
print("-------Камінь, ножниці, папір-------")
print("Вітаю тебе в моїй грі!")
print("Гра складається з трьох раундів")
print("Виграє той, хто набере більше балів")
print("\t[r] - камінь\n\t[p] - папір\n\t[s] - ножниці")
player_score = 0
player_select = 0
comp_score = 0
comp_select = 0
print("-----------------------------")
print("-----------------------------")
for i in range (3) :
print("\t--------ROUND №" + str(i + 1) + "--")
comp_select = random.choice("rps")
while True:
player_select = input ("\tYour choice:")
if (player_select == "r") or (player_select == "s") or (player_select == "p"):
break
else:
print("\tError")
print("\tComputer:" + comp_select)
if player_select == comp_select:
print("\tНічія!")
elif player_select == "r" and comp_select == "s":
player_score = player_score + 1
print("\tТи виграв!")
elif player_select == "r" and comp_select == "p":
comp_score = comp_score + 1
print("\tКомп'ютер виграв!")
elif player_select == "p" and comp_select == "r":
player_score = player_score + 1
print("\tТи виграв!")
elif player_select == "p" and comp_select == "s":
comp_score = comp_score + 1
print("\tКомп'ютер виграв!")
elif player_select == "s" and comp_select == "p":
player_score = player_score + 1
print("\tТи виграв!")
elif player_select == "s" and comp_select == "r":
comp_score = comp_score + 1
print("\tКомп'ютер виграв!")
print("-----------------------------------")
print("------------Результат гри------------")
if player_score > comp_score:
print("Вітаємо! Ви виграли!")
elif player_score < comp_score:
print("Комп'ютер виграв, але нічого! Ви зможете!'")
else:
print("Нічія!")
a = input("Продолжить? y/n\n>>>").lower()
while True :
if a==("y"):
print(str(comp_score) + " в бота")
print(str(player_score) + " в игрока")
elif a==("n"):
print(str(comp_score) + " в бота")
print(str(player_score) + " в игрока")
break
input()
else :
print("ERROR!")
break
input()
def start_game(): print("------------------------------------") print("-------Камінь, ножниці, папір-------") print("Вітаю тебе в моїй грі!") print("Гра складається з трьох раундів") print("Виграє той, хто набере більше балів") print("\t[r] - камінь\n\t[p] - папір\n\t[s] - ножниці") player_score = 0 player_select = 0 comp_score = 0 comp_select = 0 print("-----------------------------") print("-----------------------------") for i in range (3) : print("\t--------ROUND №" + str(i + 1) + "--") comp_select = random.choice("rps") while True: player_select = input ("\tYour choice:") if (player_select == "r") or (player_select == "s") or (player_select == "p"): break else: print("\tError") print("\tComputer:" + comp_select) if player_select == comp_select: print("\tНічія!") elif player_select == "r" and comp_select == "s": player_score = player_score + 1 print("\tТи виграв!") elif player_select == "r" and comp_select == "p": comp_score = comp_score + 1 print("\tКомп'ютер виграв!") elif player_select == "p" and comp_select == "r": player_score = player_score + 1 print("\tТи виграв!") elif player_select == "p" and comp_select == "s": comp_score = comp_score + 1 print("\tКомп'ютер виграв!") elif player_select == "s" and comp_select == "p": player_score = player_score + 1 print("\tТи виграв!") elif player_select == "s" and comp_select == "r": comp_score = comp_score + 1 print("\tКомп'ютер виграв!") print("-----------------------------------") print("------------Результат гри------------") if player_score > comp_score: print("Вітаємо! Ви виграли!") elif player_score < comp_score: print("Комп'ютер виграв, але нічого! Ви зможете!'") else: print("Нічія!") a = input("Продолжить? y/n\n>>>").lower() while True : if a==("y"): print(str(comp_score) + " в бота") print(str(player_score) + " в игрока") elif a==("n"): print(str(comp_score) + " в бота") print(str(player_score) + " в игрока") break input() else : print("ERROR!") break input()
Есть способ легче?создать 2 модуля один для запуска другой с кодом игры
game = 'ON' while game == 'ON': import start_game # тут запуск твоей игры game = input('Повторить введите - ON')