iT邦幫忙

第 12 屆 iThome 鐵人賽

0

在我們有Day9串列的基礎之後,讓我們來試試看這些程式碼吧!

[In]
drinks=['cola','water','juice']
fruit=['apple','orange','bananna','pineapple']
change = [1, 'pennies', 2, 'dollars', 3, 'millions']

for number in drinks:
    print(f"There have {number}. ") #字串格式化
for fruits in fruit:
    print(f"There have {fruits} juice.") #字串格式化
for x in change:
    print(f"i got {x}")
element=[]

for x in range(0,5):
    print(f"Adding{x} in the list")
    element.append(x)
for x in element:
    print(f"element was:{x}")
[Out]
There have cola. 
There have water. 
There have juice. 
There have apple juice.
There have orange juice.
There have bananna juice.
There have pineapple juice.
i got 1
i got pennies
i got 2
i got dollars
i got 3
i got millions
Adding0 in the list
Adding1 in the list
Adding2 in the list
Adding3 in the list
Adding4 in the list
element was:4
element was:4
element was:4
element was:4
element was:4

結語:

目前已經完賽1/3了,各位是否有在前10篇文學到東西呢XD。


上一篇
Day9:串列(list)
下一篇
Day11:while循環
系列文
笨方法學python 大家來一起開心學python XD12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言