1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
info = 'my name is xiaomu'
info_list = info.split() print(info_list)
if info_list[0] == 'xiaomu': print(1) info_list[0] = 'dewei'
if info_list[1] == 'xiaomu': print(2) info_list[1] = 'dewei'
if info_list[2] == 'xiaomu': print(3) info_list[2] = 'dewei'
if info_list[-1] == 'xiaomu': print(4) info_list[-1] = 'dewei'
print(info_list) info = ' '.join(info_list) print(info)
info = 'my name is dewei, i am a pythoner, i love python' info_list = info.split()
if info_list[0] in ['python', 'i']: info_list[0] = '*'
if info_list[1] == 'python' or info_list[1] == 'i': info_list[1] = '*'
if info_list[2] == 'python' or info_list[2] == 'i': info_list[2] = '*'
if info_list[3] == 'python' or info_list[3] == 'i': info_list[3] = '*'
if info_list[4] == 'python' or info_list[4] == 'i': info_list[4] = '*'
if info_list[5] == 'python' or info_list[5] == 'i': info_list[5] = '*'
if info_list[6] == 'python' or info_list[6] == 'i': info_list[6] = '*'
if info_list[7] == 'python' or info_list[7] == 'i': info_list[7] = '*'
if info_list[8] == 'python' or info_list[8] == 'i': info_list[8] = '*'
if info_list[9] == 'python' or info_list[9] == 'i': info_list[9] = '*'
if info_list[-1] in ['python', 'i']: info_list[10] = '*'
print(info_list)
info = ' '.join(info_list) print(info)
info = 'my name is dewei' print(len(info))
if len(info) > 10 and len(info) != 16: print(info.replace('dewei', 'xiaomu'))
print('finish')
|