test = [
{'input':{'nums': [19, 25, 29, 3, 5, 6, 7, 9, 11, 14]}, 'output': 3},
{'input':{'nums': [6, 8, 9, 10, 11, 1, 3, 5]}, 'output': 5}
]
def count_rotations_binary(nums):
pass
我怎樣才能用上面的串列呼叫這個函式?
uj5u.com熱心網友回復:
您可以在呼叫函式時簡單地提供串列的名稱作為實際引數。您不需要在函式宣告中提供任何預期型別。
test = [
{'input': {'nums': [19, 25, 29, 3, 5, 6, 7, 9, 11, 14]}, 'output': 3},
{'input': {'nums': [6, 8, 9, 10, 11, 1, 3, 5]}, 'output': 5}
]
# This prints whatever you give to it
def count_rotations_binary(nums):
print(nums)
# Pass the entire list
count_rotations_binary(test)
# Pass only the 'nums' value
for item in test:
count_rotations_binary(item['input']['nums'])
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/410033.html
標籤:
下一篇:Python-使用PyGitHubget_contents從github下載yaml檔案并嘗試將其轉換為dict
