1樓:天祿歸來
# write your code below!
def compute_bill(food):
total = 0
for a in food:
total = total + prices[a]return total
2樓:追尋
def compute_bill(food):
total = 0
for key in food:
total = prices[key] + totalreturn total
print compute_bill(shopping_list)
關於python的列表問題!!求大神!!
3樓:匿名使用者
#先宣告,本人也是初學者,採用了乙個比較笨的辦法a = ["aaa","ddd","ccc"]b = ["aaa","ddd","eee"]text = input("輸入:")
if a[0] in text and a[1] in text:
print(a,b)
elif a[2] in text:
print(a)
elif b[2] in text:
print(b)
else:
print('not found')
#第二個也是一樣的,都是對陣列切片,然後與輸入字串比較,符合要求就輸出
a = ["123","124","125"]b = ["123","124","126"]text = input("輸入:")
if a[0] in text and a[1] in text:
print(a,b)
elif a[2] in text:
print(a)
elif b[2] in text:
print(b)
else:
print('not found')
4樓:匿名使用者
text = input("輸入:")
a = ["aaa","ddd","ccc"]b = ["aaa","ddd","eee"]if text.find('aaa')>-1 and text.find('ddd')>-1:
print(a,b)
elif text.find('ccc')>-1:
print(a)
elif text.find('eee')>-1:
print(b)
5樓:匿名使用者
>>>l命令使用擷取指令,可以實現你的要求。
關於python乙個列表的問題!!求大神解答!!
6樓:匿名使用者
def is_str_in_string(**all_string, big_string):
return **all_string in big_stringdef has_str_in_string(the_list, big_string):
for **all_string in the_list:
if **all_string in big_string:
return true
return false
a = ["abc", "ggg"]
b = ["kkk", "sss"]
text = input("請輸入:")
while true:
if has_str_in_string(a, text) and has_str_in_string(b, text):
print("game over!")
break
text = input("請重新輸入:")
python中關於列表中元素的處理,求大神指導!!!
7樓:
轉換型別即可 tuple(b)
8樓:匿名使用者
tuple(b)就行了
關於python的小問題,關於python的乙個小問題?
python range 函式可建立乙個整數列表,一般用在 for 迴圈中。函式語法range start,stop step 引數說明 start 計數從 start 開始。預設是從 0 開始。例如range 5 等價於range 0,5 stop 計數到 stop 結束,但不包括 stop。例如...
關於python問題
縮排問題。寫python要十分注意縮排。def buildconnectionstring params build a connection string from a dictionary returns string.what s this if name main myparams serv...
模組物件沒有屬性列表Python 3問題,怎麼解決
username stringvar self.uentry1 ttk.entry self.frame1,textvariable username self.uentry1.pack self.ubutton ttk.button self.frame1,text name 6261696475...