choice = input('Are you ready to start the test (Y/N): ')
print (choice)
while choice not in ['Y','N',]:
choice = input('Invalid choice. Are you ready to start the test (Y/N): ')
print(choice)
if choice == 'N':
sys.exit
if choice == 'Y':
print('Test starts in 3...')
time.sleep(1)
print('2...')
time.sleep(1)
print('1...')
time.sleep(1)
countdown(t)6
print('BEGIN')
输出:
Welcome to type test
You will be given sixty seconds to type as many correct words as possible!
Are you ready to start the test (Y/N): Y
Y
答案 0 :(得分:1)
我在本地使用了您的代码,缩进如下,并且运行良好:
import time
import sys
choice = input('Are you ready to start the test (Y/N): ')
print (choice)
while choice not in ['Y','N',]:
choice = input('Invalid choice. Are you ready to start the test (Y/N): ')
print(choice)
if choice == 'N':
sys.exit
if choice == 'Y':
print('Test starts in 3...')
time.sleep(1)
print('2...')
time.sleep(1)
print('1...')
time.sleep(1)
#countdown(t)
print('BEGIN')