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

21st Jan 2022, 10:55 AM
Manoj Bhaagam
5 Réponses
+ 2
And, what is your question?
21st Jan 2022, 10:57 AM
Shadoff
Shadoff - avatar
+ 2
Manoz Bagam s = "krinshnaa" output = {} for i in s: output [i] = s.count(i) print(output)
22nd Jan 2022, 3:00 PM
Shubham jadhav
Shubham jadhav - avatar
+ 1
You haven't even tried yet? Can you show us your code?
21st Jan 2022, 12:04 PM
Shadoff
Shadoff - avatar
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
21st Jan 2022, 11:01 AM
Manoj Bhaagam
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.
21st Jan 2022, 8:06 PM
Brian
Brian - avatar