Convert from “For-loops” to “While-loops”

后端 未结 3 829
囚心锁ツ
囚心锁ツ 2020-12-12 06:15

I\'ve approached this question that I\'m struggling to solve. It\'s asking me to convert the code from \"for-loops\" to \"while-loops\":.

def print_names2(pe         


        
3条回答
  •  攒了一身酷
    2020-12-12 06:31

    Maybe here's what you want:

    def print_names(people):
      while people:
        p = people.pop()
        n = ''
        while p:
          n += p.pop() + ' '
        print n
    

提交回复
热议问题