2017-09-09 6 views
0

下部には(23など)をスキップしていますが、その理由はわかりません。Pythonが無視されている場合

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) 
+3

'入力は()'文字列を返します、あなたはそれらの – PRMoureu

+0

の1が入力文字列と '「1」で変換し、整数に比較! = 1 ' –

+1

(少なくともPython3では) – jedwards

答えて

2

input()はPython3で文字列を返します。

だからCtypeは文字列です。整数と比較すると、等価チェックは失敗します。

このように、int型に文字列を変換します

Ctype = int(Ctype) 
+1

今すぐ試してみましょう。うん、それは意味を成し遂げ、将来を考えているだろう。感謝。 –

+0

良い@TGBFProjectは、答えを受け入れる! =) – gsamaras

関連する問題