- 3

How can I count length of each item in a list

Counting letter of word

26th Mar 2022, 9:14 AM
Reza Jaferyan
Reza Jaferyan - avatar
4 odpowiedzi
+ 3
Mention the language as well. Though i'm assuming you're asking this in Python. You can do this by creating a loop and targeting each value. a = ['hello','hi','bye'] for i in range(len(a)): print(len(a[i]))
26th Mar 2022, 9:33 AM
zexu knub
zexu knub - avatar
+ 3
It's better to avoid using range(len()) thing unless you need to work with indices of a sequence. for i in a: print(len(i)) List comprehension length = [len(i) for i in a]
26th Mar 2022, 10:02 AM
Simba
Simba - avatar
+ 1
If it's in JavaScript just loop through it and check the length var x=["ego","chigozie","money"] for (var i = 0; i < x.length; i++) { console.log(x[i].length) }
26th Mar 2022, 10:39 AM
Chigozie Anyaeji 🇳🇬
Chigozie Anyaeji 🇳🇬 - avatar