0
hi
what's wrong with this code?? list = ['a','b','c','d','a','f','g','h','a'] print(len('a')) why it prints 1 instead of 3???
6 Respostas
+ 2
Because your text size is 1
+ 1
Younes.Ebrahimi
If you wanna print how many 'a' in list,
you can write like that
print(list.count('a'))
0
so how should i write a program that says how many 'a' do we have in the list??
0
In your code you asked to print the lenght for “a” which is one letter thus the output was 1
To find the number of an element in your list use the count method:
print(list.count(“a”))
0
thank you very much
0
yes i solved it thank you guys