[Tutor] Query: lists

Deepti K kdeepti2013 at gmail.com
Tue Aug 14 04:11:07 EDT 2018


 when I pass ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] as words to the below
function, it picks up only 'xzz' and not 'xaa'

def front_x(words):
  # +++your code here+++
  a = []
  b = []
  for z in words:
    if z.startswith('x'):
      words.remove(z)
      b.append(z)
      print 'z is', z
  print 'original', sorted(words)
  print 'new', sorted(b)
  print sorted(b) + sorted(words)

Thanks,
Deepti


More information about the Tutor mailing list