【发布时间】:2015-01-26 18:48:00
【问题描述】:
我正在编写一个程序,它接受用户输入并将其保存在一个数组中。我目前正在尝试编写一个编辑数组中数据的函数。到目前为止,我有:
data = []
user_input = int(raw_input('How many Subject do you wish to add? : '))
for i in range (0, user_input):
x = raw_input('Enter Subject: ')
data.append(x)
print(data)
【问题讨论】:
-
到目前为止,您在尝试编写的函数中做了什么?另外,您要编辑什么?
-
看来您已成功将数据存储到数组中。您尝试以何种方式编辑数据?
-
为什么我不能编辑这个问题以使代码可读?编辑按钮是灰色的。
-
是的,一旦数组被项目填充。我的代码中的下一个函数询问用户是否要编辑保存在数组中的任何项目。到目前为止,我已经编写了这样的代码: yes = 1 no = 2 print "would you like to add/remove any items in list" print "1: yes" print "2: no" edit_input = int(raw_input('choose?: ' )) 如果edit_input == 1:打印(数据)
-
@W0rmSp17 请粘贴您的整个代码..
标签: python arrays python-3.x edit