mood = False
if mood:
print('go to left')
else:
print('go to right')
ACCOUNT = 'DaHongHong'
PASSWORD = '123456'
print('please input account')
USER_ACCOUNT = input()
print('please input password')
USER_PASSWORD = input()
if ACCOUNT == USER_ACCOUNT and PASSWORD == USER_PASSWORD:
print('success')
else:
print('fail')
a = input() #接收到的为str类型,需要转换成int
a = int(a)
if a == 1:
print('apple')
elif a == 2:
print('orange')
elif a == 3:
print('banana')
else:
print('shopping')
counter = 1
while counter <= 10:
counter += 1
print(counter)
else:
print('EOF')
a = ['apple', 'orange', 'banana', 'grape']
for x in a:
print(x)
b = [['apple', 'orange', 'banana', 'grape'], (1, 2, 3)]
for x in b:
for y in x:
print(y, end=' ')#横向打印,并以空格为分隔
#打印1
a = [1, 2, 3]
for x in a:
if x == 2:
break
print(x)
#打印1 3
a = [1, 2, 3]
for x in a:
if x == 2:
continue
print(x)
#表示0-9
for x in range(0,10):
print(x, end=' ')
#表示0,2,4,6,8 2表示步长
for x in range(0,10,2):
print(x, end=' ')
#表示10,8,6,4,2
for x in range(10,0,-2):
print(x, end=' ')
#表示1,3,5,7
a = [1, 2, 3, 4, 5, 6, 7, 8]
for i in range(0, len(a), 2):
print(a[i], end=' ')
#表示1,3,5,7
b = a[0:len(a):2]
print(b)