python-for其他用法補充
grade_list = [("小雞", 100), ("兩大類", 0), ("小喵", 80), ("小蟲", 60)] for item in grade_list: print (item[0], item[1]) print ('---------------------') # 可以直接改寫 for (name, grade) in grade_list: print (name, grade) print ('---------------------') # 或是這樣 for name, grade in grade_list: print (name, grade) print ('---------------------') num_list = [1, 2, 3] for num in num_list: print (num) num_list.remove(num) print (num_list) print ('---------------------') num_list = [1, 2, 3] for num in num_list[:]: print (num) num_list.remove(num) print (num_list) print ('---------------------') fruits = ['apple', 'banana', 'orange'] for i in fruits: print(i) print ('---------------------') fruits = ['apple', 'banana', 'orange'] for i in range(len(fruits)): print(fruits[i]) print ('---------------------') # 反轉 fruits = ['a