所以我有这段代码,我试图从中创建一个任务管理器,它接受用户输入并将其放在新文件内的列表中。当我运行它并键入 exit 时,它给了我这个错误:TypeError: '<' not supported between 'str' and 'int' instnaces。
这是代码:
print('WELCOME TO YOUR TASK MANAGER!')
filename = input('What would you like your filename to be: \n(Please type \'.txt\' at the end of the
name)');
tasks = []
with open(filename, 'w+') as f:
prompt = 'Please enter what you need to do: \n(separated by commas and a space. Ex: laundry, clean) \n When you are done puting in tasks please type \'exit\' '
user_input = f.write(input(prompt).strip())
while (user_input != 'exit'):
tasks.append(user_input)
user_input = input(prompt).strip()
tasks.sort()
print('\nAlphabetical order:')
for task in tasks:
print(task)
有想法该怎么解决这个吗?
牛魔王的故事
慕婉清6462132
相关分类