3月21日學習日記

yicoder發表於2019-03-21

學習了從入門到實戰的第七章while迴圈和第八章的函式部分

while 迴圈的使用很靈活 for迴圈不應修改連結串列,而while迴圈則可以遍歷的同時進行修改.

unconfiremed_users = ['alice', 'brian', 'candace']
confirmed_users = []
while unconfirmed_users:
    current_user = unconfirmed_users.pop()
    print('Verifying user: ' + current_user.title())
    confirmed_users.append(current_user)
    
print('\nThe following users have been confirmed:')
for confirmed_user in confirmed_users:
    print(confirmed_user.title())
 
複製程式碼

python的函式引數有預設值和關鍵字實參