0
im ish pythonとiveがこのコードを持っていて、入力時に「exit」という単語をいつでも入力できるようにしたい。それが完了すると、スクリプトを閉じます。ループから抜け出すpython 3
本当にありがとうございます。
import sys
while True:
def inputs():
first=input("Enter your first name: ")
last=input("Enter your last name: ")
gender=input("Enter your gender: ")
form=input("Enter your form: ")
file = open("signup.txt", "a")
#Records the user's details in the file
file.write("\nFirst name: "+first+", Last name: "+last+", Gender: "+gender+", Form: "+form)
#Closes the file
file.close()
if input(inputs) == "exit":
sys.exit()
inputs()
ここにループはありません。 –