# type
a = 10 # number
b = '1' # string
c = [1,2,3] # list
🌵🌵🌵🌵🌵🌵
# 字符串切片
s = 'python'
#index 012345
print(s[0]) # get value p from string
print(s[3]) # h
print(s[::-1]) #transpose nohtyp
print(s[0:2:1]) # py 0 1
string_name[start_value:end_value:steps]
# The start value indicates the start point
# steps indicates how many I add each time
# end_value indicates the end point ,but the number doesn't show
print(s[0:5:2]) # pto 0 2 4
🐰练习
# test
d = 'nihaoyaqingti'
# 0123456789 10 11 12
print(d[1:11:3]) # ioqg 1 4 7 10
# test2
# there is a 3-digit number,and when you add 396,
# it reverses the original number .
# fin all of these 3-digit numer.
# such as 105+396=501
# create number 100~999 100 101 102 103 104.....999
for x in range(100,1000):
s = x+396 # add 396,it reverses the original number .105+396
s = str(s) # change the type to string
c = s[::-1] # reverse 501----->105
c = int(c) # change type to number(integer)
if x==c:
print(x)
#homework
1,please enter a number,judge if the number is a palindrome.
such as 1001 2002 1991 3113 symmetry
2,
f = 'abcdefgh'
print(f[1:6:2]) # result is ?
print(f[2:8:3]) # result is ?
print(f[0:3:1]) # result is ?
print(f[2:5:3]) # result is ?
'dfh'
'aceg'
'hgfedcba'