Commit f5873072 by BellCodeEditor

auto save

parent a430864b
Showing with 17 additions and 9 deletions
message = "诺依,周末一起去看动漫展吧!" # 序列拆包:右侧一个序列,左侧多个遍历
tuple_surname = "黄", "孙", ["红", "黄", "绿"]
print(type(tuple_surname))
a, b, c = tuple_surname
print(a, b, c) # "黄", "孙", "钱"
print(type(c))
list_color = [["红", "黄", "绿"], "黄", "绿"]
a, b, c = list_color
print(a, b, c) # "红", "黄", "绿"
print(type(a))
a, b, c = "[1,2,3]禄寿"
print(a, b, c) # "福", "禄", "寿"
print(type(a))
# 请对message进行遍历,取出所有元素 # 变量交换:a,b=b,a
name01 = "小华"
name02 = "小明"
#[start]added by teacher, print in a line name01, name02 = name02, name01 # 相当于序列拆包的 name01,name02 = (name02, name01)
for items in message:
print(items, end=' ')
print()
#[end]added by teacher, print in different line
for items in message:
print(items)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment