Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def right_words(alist, number): #this function accepts a list of strings and a number
- new_list = [] # an empty list to contain the new list generated
- for num in alist: # a for loop to loop through every
- if len(num) == number: # this returns true if the length of the string is equal to the value of the variable number
- new_list.append(num)
- return new_list # returns a newly generated list containing the results from the loop
- print(right_words([], 4))
Add Comment
Please, Sign In to add comment