• XSS.stack #1 – первый литературный журнал от юзеров форума

Простая игра на Python

Edelveis

floppy-диск
Пользователь
Регистрация
15.11.2019
Сообщения
4
Реакции
1
Python:
import random
print('GhostGame')
print()
flag = 'Yes'
while flag == 'Yes':
    userScore = 0
    userChoice = 0
    doorCount = int(input('Enter the number of door: '))
    ghostIndex = 0
    while True:
        for i in range (doorCount):
            print('__[' + str(i+1)+']__', end = '')
        print()
        userChoice = int(input('Choose your door from 1 to ' + str(doorCount)+': '))
        ghostIndex = random.randint(1, doorCount)
        print()
        print('Ghost is here: ')
        for i in range (doorCount):
            if i+1 != ghostIndex:
                print('__[   ]__', end = '')
            else:
                print('__[ X ]__', end = '')
        print()
        print('You is here: ')
        for i in range(doorCount):
            if i + 1 != userChoice:
                print('__[   ]__', end='')
            else:
                print('__[ O ]__', end='')
        if userChoice == ghostIndex:
            break
        else:
            userScore += 1
            print()
            print(userScore)
    print()
    print('Game over')
    print('Your score:', + userScore)
    flag = input('Would you like to play agaim ?' + ' Yes or No ')
    i = 0
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх