#6.输入3个字母:e、a、r,如果输入e,那么退出循环,如果输入a,执行continue,如果输入r,那么再读取一次字母,并打印,只允许输入三次字母,重复输入的字母不算在内。
#count = 0 #for i in range(3): # letter = input("send a letter%d:"%i) # if letter == 'e': # break # elif letter == 'a': # continue # elif letter == 'r': # count += 1 # if count == 2: # input("send a letter dddd:")
#7.把一个字符串"abcdefg"插入到一个list中,每个字母占一个list中的元素位置,例如:["a","b","c","d","e","f","g"] ls=["a","b","c","d","e","f","g"] s="abcdefg" lt=[] # #插入元素到后边 # for i in s : # ls.extend(i) # print(ls) # # for i in s: # ls.append(i) # print(ls) # #每个元素都插在第一个,或者说倒序插入列表前边 # for i in s: # ls.insert(0,i) # print(ls) # #8.['a','b','c','d','e','f','g']操作这个list,拼出一个字符串"adg" # lis=['a','b','c','d','e','f','g'] # print(len(lis)) # t=lis[0]+lis[int(len(lis)/2)]+lis[-1] # print(t) #或 # print("".join(lis[::3]))