#test
import subprocess
import time
import random
programClass=[]
code=random.randint(100,1000)
print('This is your secret code! PLEASE WRITE THIS DOWN!')
print(code)
numRafflePeople=0
tester=1
while tester==1:
code1=input('What is your name, phone number, and email?\n')
print('code',code1)
code=code
if code==code1:
print('Blah')
time.sleep(5)
tester=2
else:
print('fail')
tester=1
このプログラムは乱数を作成し、入力された数値が乱数と同じかどうかを確認しますプログラムは同じではないと識別することができないようです。Pythonプログラムでランダムな整数にコードを割り当て、ユーザー入力が機能していないことを確認します
乱数は303のようになります。私は303を入力し、失敗メッセージが表示されます。誰かが私のコードでエラーを説明できますか?
[MCVE]を作成してみてください。 –
[入力を整数として読み取るにはどうしたらよいですか?](https://stackoverflow.com/questions/20449427/how-can-i-read-inputs-as-integers) ) –
私の望む答えが得られました。私の大きなプロジェクトではwhileループが必要ですが、それは大きいようです。 – QuestionedE