Day10:串列的循环

在我们有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)

>>:  老肝哥-菜鸟Java的LeetCode历程,第十三题:Roman to Integer,朝远大目标前进!

安装 elementary OS 6.0 与呒虾米

前言 elementary OS 6.0 (以下称 Odin) 释出後几天,我决定也来安装看看,想不...

Day03 Filebeat(一) 基本设定

在上一篇中我们已经把elk的环境设定完成,接下来将要收集log到Elasticsearch内,以方便...

Day 27:刷题

前言 刷题是应徵流程的一环,但并不是每一家公司都要,通常小公司比较不会有刷题的环节,可以把刷题想成是...

Day 21:401. Binary Watch

今日题目 题目连结:401. Binary Watch 题目主题:Backtracking, Bit...

Day 17. 来摸摸Unreal Engine吧!

决定来摸Unreal Engine(UE)怎麽使用,经过Unity的下载後,其实Unreal的下载也...