存在字符串s='shcyunaownpsj123vaw',编程统计字符串中字母n出现的次数 ,要求分别使用以下两种方式:1)用count()方法2)用for循环和if语句
s = 'shcyunaownpsj123vaw' print(s.count('n')) count = 0 for char in s: if char == 'n': count += 1 print(count)