I’m currently doing the Computer Science career path and reached the second set of code challenges
In the first challenge, we are asked to write a code to count the letters in a word, without counting repeated letters and differentiating between upper and lower case letters.
This is my code:
letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" def unique_english_letters(word): count = 0 for letter in letters: if letter in word: count += 1 return count
This code is working, it is looping through the letters and adding to the “count” variable if the condition is satisfied. However, what I don’t understand is: how Python is differentiating the letters in the string “letters” if it is just a string, not a list? Is Python using a delimiter of some kind? In other words, how does Python knows when a letter “ends” and the next one “begins”?
Thank you in advance!