按索引获取列表项
嘿我做了一个看起来像这样的程序,但我有一个问题。
选择 | 换行 | 行号
- command = raw_input(">")
- fullcommand = command.split(" ")
- #example user input: >add 10 15
- if fullcommand.index("add") == 0:
- #how I want the rest to work:
- * * *a= fullcommand.getItem(1)
- * * *b= fullcommand.getItem(2)
- * * *c= a + b
- * * *print ("Result: *" + c)
所以我需要的是一个函数,它获取索引为1的列表项和索引为2的列表项。这是如何工作的?彼得