Quick actions

cmd+k|ctrl+k

Navigation

Languages

exercise 6 - lab 2

Snippet info

Language

Python

Visibility

public

Author

hccc19

Created

2016-10-14T10:27:14Z

Updated

2016-10-16T15:11:09Z

# exercise 6 - lab 2 - Tìm ký tự xuất hiện nhiều nhất, ít nhất trong s

s = "tung beo is me, tao la tung beo, 19"

most_appear_char = s[0]
least_appear_char = s[0]
max_count = s.count(s[0])
min_count = s.count(s[0])

for ch in s:
    if s.count(ch) > max_count:
        most_appear_char = ch
        max_count = s.count(ch)
        
    if s.count(ch) < min_count:
        least_appear_char = ch
        min_count = s.count(ch)
        
print('char \'%s\' appears %d times\nchar \'%s\' appears %d times' % (most_appear_char, max_count, least_appear_char, min_count))        
    
    
INFO