For example:
"Abcdefgaj
"Array: a
A [0]=2 (two)
A [1]=1 (a b)
.
I don't think the if too much trouble
CodePudding user response:
https://www.cnblogs.com/longyuu/p/9787512.htmlCodePudding user response:
https://blog.csdn.net/qq_40674583/article/details/81591211? Utm_medium=distribute. Pc_relevant. None - task - blog - BlogCommendFromMachineLearnPai2-1. Channel_param & amp; Depth_1 - utm_source=distribute. Pc_relevant. None - task - blog - BlogCommendFromMachineLearnPai2-1. Channel_paramThere will be combined with the, can be finished
CodePudding user response:
Yet I didn't think written without the if
Input_str=input (" please enter: ")
A='
S_list=[]
# will all elements into the list
For I in input_str:
S_list. Append (I)
# to heavy
S_set=set (s_list)
For I in range (97, 123) :
# CRH (97) - & gt; A CRH (122) - & gt; Z
If CRH (I) in s_set:
A +=f '{s_list. Count (CRH) (I)}'
The else:
A +='0'
Print (a)
CodePudding user response:
Looking to a need not the if, correct:# to ensure that the input string to lowercase letters, otherwise the index out of range
Input_str=input (" please input lowercase string (no Spaces) : ')
S_list=list (input_str)
A=[0 for x in the range (26)]
For x in s_list:
A [word] (x) - 97 +=1
Print (a)
CodePudding user response:
From the collection import CounterPrint (Counter (' abcdefgaj))
Cell phone tapping, first try
CodePudding user response:
import string
The import itertools as it
S="abccdefgaj"
G=it. Groupby (sorted (s))
D={I: len (list (j)) for I and j in g}
S={" a [] {} ". The format (I) : d.g et (j, 0) for the I, j in enumerate (string. Ascii_letters)}
Print (s)
CodePudding user response:
Just use some code conversion, I don't need to botherA some code I remember is the 41 h 85
Starting from the 85 + 1