Easy_Flex

Untitled

Feb 29th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. def right_words(alist, number): #this function accepts a list of strings and a number
  2.     new_list = []  # an empty list to contain the new list generated
  3.     for num in alist:  # a for loop to loop through every
  4.         if len(num) == number: # this returns true if the length of the string is equal to the value of the variable number
  5.             new_list.append(num)
  6.  
  7.     return new_list   # returns a newly generated list containing the results from the loop
  8.  
  9.  
  10. print(right_words([], 4))
Add Comment
Please, Sign In to add comment