โ
Output Revealed!
Did the "isalpha()" + "isdigit()" trick you? ๐
Actual Output:
21
๐ก Explanation:
The condition checks "word.isalpha()" OR "ch.isdigit()".
- ""dhoni07"" โ only the 2 digits ("0", "7") satisfy the condition โ count decreases by 2.
- ""virat18"" โ only the 2 digits ("1", "8") satisfy the condition โ count decreases by 2.
- ""Rohit"" โ the entire word is alphabetic โ all 5 characters satisfy the condition โ count decreases by 5.
So the total becomes:
30 โ 2 โ 2 โ 5 = 21
๐ฏ Final Output: 21
๐ Key Takeaway
Even though "word.isalpha()" is checked inside the inner loop, it evaluates the entire word, not the individual character. For the first two words, only digits trigger the condition, while every character in ""Rohit"" triggers it.
๐ฌ Did you predict 21? Comment "Got it!" if you were right, or share your guess before seeing the answer!