lis1=[]print("the list before initialisation:",str(lis1))lis1=[chr(characters)forcharactersinrange(ord("A"),ord("Z")+1)]print("the list after initialisation:",str(lis1)) Python Copy 输出 thelistbefore initialisation:[]thelistafter initialisation:['A','B','C','D','E','F'...
a = "chocolate" b = list(a) for i in range(len(b)): c = 0 for j in range(len(b)): if b[i] == b[j]: c += 1 print(b[i],c) i did this, it counted the elements but printed the elements twice i also wanted to find the duplicates location in the string like c = ...