Python定義函數修改列表中元素,並返回顯示

原列表:username=['Larry','Marry','Smith']

新列表:new_names=['the Great Smith','the Great Marry','the Great Larry']

 

def make_great(names):
    while names:
        current_name='the Great '+names.pop()
        new_names.append(current_name)
    return new_names

def show_magicians(names):
    for name in names:
        print(name)
        
new_names=[]
username=['Larry','Marry','Smith']
new_names=make_great(username)
show_magicians(new_names)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章