0
s = 'kkkrisnaaa'
I need output like this output = {'k' : 3, 'r' : 1,'i' : 1,'s':1,'n' : 1'a' : 3} by using above string I want to Convert above string to dictionary
5 Respostas
+ 2
And, what is your question?
+ 2
Manoz Bagam
s = "krinshnaa"
output = {}
for i in s:
output [i] = s.count(i)
print(output)
+ 1
You haven't even tried yet?
Can you show us your code?
0
s='kkkrishnaaa'
I need output like this = {'k' : 3, 'r' : 1,'i' : 1,'s':1,'n' : 1'a' : 3} by using above string
I want to Convert above string to dictionary
0
Manoz Bagam it is possible to do within a couple lines of code. A solution might involve iterating through each character in the string and using the count() method to build up a dictionary and print the result.