Jan-27-2019, 05:43 PM
Hello friends,
This is our assignment:
Write a function called stop_at_z that iterates through a list of strings. Using a while loop, append each string to a new list until the string that appears is āzā. The function should return the new list.
I have came up with this:
https://pasteboard.co/HYpOEuJ.png
Can somebody help?
Thank you
This is our assignment:
Write a function called stop_at_z that iterates through a list of strings. Using a while loop, append each string to a new list until the string that appears is āzā. The function should return the new list.
I have came up with this:
def stop_at_z(testlist): index = 0 result = [] while index < len(testlist): if "z" in testlist[index]: index += 1 continue result.append(testlist[index]) index += 1 return resultBut I receive error!
https://pasteboard.co/HYpOEuJ.png
Can somebody help?
Thank you