0
l = []
print("We will need some information first.")
t_first_name = input("User First Name: ").lower()
while len(t_first_name) == 0 or t_first_name == ' ':
t_first_name = input("User First Name: ").lower()
while len(t_last_name) == 0 or t_last_name == ' ':
t_last_name = input("User Surname: ").lower()
f_n_up = t_first_name.upper()
l_n_up = t_last_name.upper()
f_n_title = t_first_name.title()
l_n_title = t_last_name.title()
l.append(t_first_name) # Lowercase
l.append(t_last_name)
l.append(f_n_up) # Uppercase
l.append(l_n_up)
l.append(f_n_title) # The first letter is uppercase
l.append(l_n_title)
f = open("p_list.txt", "a")
for x in l:
print(x)
if len(x) >= 5:
f.write(x)
print("test")
print
の行が表示され、ファイルが作成されますが、ファイルを開くとその中に単語が見つかりません。ファイルに書き込めません - python
ユーザ名を尋ねてリストを作成し、リストl
に追加して、その中にループを作り、その文字列をファイルに書き込みます。
おかげで、それは正常に動作します – Anonymous