如何更改此函数调用和算法以在大小为 n 的列表中找到具有最小值的字符串。我也知道内置的 min 函数,我只是想了解机制。让我先说我是第一学期的CS学生,所以我提前为我的无知道歉。
def main():
strOne = 'stack'
strTwo = 'over'
strThree = 'flow'
strFour = 'please'
strFive = 'help'
first = alphabetical(strOne, strTwo, strThree, strFour, strFive)
print(first)
def alphabetical(one, two, three, four, five):
low = one
if two < low:
low = two
if three < low:
low = three
if four < low:
low = four
if five < low:
low = five
return low
main()
###################################################################
# str_list = ['stack', 'over', 'flow', 'please', 'help'] ?? #
# for i in str_list: ?? perhaps on the right track with this idea.#
# first = alphabetical(i) ?? maybe #
###################################################################