Complete the code to create a dictionary to count characters.
count = [1]()We use dict() to create a dictionary for counting characters.
Complete the code to increment the count of character c in the dictionary.
count[c] = count.get(c, 0) [1] 1
We add 1 to the current count to increment the character count.
Fix the error in the loop to find the first non-repeating character.
for c in s: if count[c] == [1]: return c
The first non-repeating character has a count of exactly 1.
Fill both blanks to complete the function that returns the first non-repeating character or '_' if none.
def first_non_repeating(s): count = dict() for c in s: count[c] = count.get(c, 0) [1] 1 for c in s: if count[c] == [2]: return c return '_'
We increment counts by 1 and check if count equals 1 for non-repeating characters.
Fill all three blanks to create a dictionary comprehension that counts characters appearing more than once.
count = [1]( (c, s.count(c)) for c in s if s.count(c) [2] [3] )
We use dict to create the dictionary, check if count is greater than 1 to find repeating characters.