Skip to content

Instantly share code, notes, and snippets.

@mayankdawar
Created February 19, 2020 17:47
Show Gist options
  • Save mayankdawar/bea4eef0b9001821f8179daf037d2d0c to your computer and use it in GitHub Desktop.
Save mayankdawar/bea4eef0b9001821f8179daf037d2d0c to your computer and use it in GitHub Desktop.
For each string in the list words, find the number of characters in the string. If the number of characters in the string is greater than 3, add 1 to the variable num_words so that num_words should end up with the total number of words with more than 3 characters.
words = ["water", "chair", "pen", "basket", "hi", "car"]
num_words = 0
for i in words:
if len(i) > 3:
num_words += 1
@Maksimovprojects
Copy link

Maksimovprojects commented Sep 23, 2021

isn't right. Your loop statement means: for words less than 3 characters.... Read the task carefully: "in the string is greater than 3"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment