fork download
  1. def satisfiesF(L):
  2. """
  3. Assumes L is a list of strings
  4. Assume function f is already defined for you and it maps a string to a Boolean
  5. Mutates L such that it contains all of the strings, s, originally in L such
  6. that f(s) returns True, and no other elements
  7. Returns the length of L after mutation
  8. """
  9. for e in L:
  10. if not f(e):
  11. alis.remove(e)
  12. print len(L)
  13. print L
  14. def f(x):
  15. return 'a' in x
  16.  
  17. satisfiesF(['ava','nlki','qorqorj','jaja'])
  18. satisfiesF([])
  19. satisfiesF(['','fafs'])
  20.  
Runtime error #stdin #stdout #stderr 0.01s 9008KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 17, in <module>
  File "prog.py", line 11, in satisfiesF
NameError: global name 'alis' is not defined