它在底部跳过if Ctype == 1
(2
,3
等),不明白为什么。
print("Starting game.")
print("Game Started.")
print('\n')
CharName = input('Create a character name: ')
print('\n' * 20)
print('Class Selection: (Ensure it as written as you read it)')
print('\n')
print('Classes:')
print('[1] Heavy')
print('[2] LightFooted')
print('[3] Warrior')
print('\n')
print('To Come:')
print('Stealth')
print('\n')
Ctype = input('Choose class: ')
if Ctype == 1:
print('test')
if Ctype == 2:
print('test')
if Ctype == 3:
print('test')
if Ctype == 4:
print('Try again... another time.')
time.wait(2)
答案 0 :(得分:2)
input()
在Python3中返回一个字符串。
所以Ctype
是一个字符串。然后比较一个整数,因此等式检查失败。
将字符串转换为int,如下所示:
Ctype = int(Ctype)