Last active
January 28, 2019 10:10
-
-
Save elleryq/5910ab4b12daf8cb79c3477df3ddb19f to your computer and use it in GitHub Desktop.
Rewrite using while
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| players = [ | |
| ['james', 202], | |
| ['curry', 193], | |
| ['durant', 205], | |
| ['jordan', 199], | |
| ['david', 211]] | |
| players_iter = iter(players) | |
| player = next(players_iter, None) | |
| while player: | |
| if player[1] >= 200: | |
| print(player) | |
| player = next(players_iter, None) | |
| #### | |
| # Another | |
| #### | |
| #!/usr/bin/python3 | |
| #players = [ | |
| # ['james', 202], | |
| # ['curry', 193], | |
| # ['durant', 205], | |
| # ['jordan', 199], | |
| # ['david', 211]] | |
| #players_iter = iter(players) | |
| #while True: | |
| # try: | |
| # player = next(players_iter) | |
| # if player[1] < 200: | |
| # continue | |
| # print(player) | |
| # except StopIteration: | |
| # break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment