Variable exchange
a,b = 3,7
print(a,b)
a,b = b,a
print(a,b)
Numerical comparison
a = 5
if 1 < a < 10:
print("Yes")
else:
print("No")
a = 5
print("Yes" if 1 < a < 10 else "No")
Print N times
print("$" * 10)
Initialize the value of the list
l = [0] * 5
print(l)
Traversal sequence
color = ["red","green","blus","yellow"]
for i in color:
print(i)
Unfold sequence
color = ["red","green","blus","yellow"]
color1,color2,color3,color4 = color
print(color1)
print(color2)
print(color3)
print(color4)
String conversion list
s = "I Love You"
l = s.split()
print(l)
List conversion string
l = ["I","Love","You"]
s = " ".join(l)
print(s)
Convert a list of numeric strings to an integer list
l = ["23","83749","432"]
new_l = list(map(int,l));
print(new_l)
Iterate over two lists simultaneously
name = ["张三","李四","王二","麻子"]
age = [12,34,45,76]
for x,y in zip(name,age):
print("%s%d岁"%(x,y))