From 26b8e3034455c070f0d0b1113aa5048d3191a802 Mon Sep 17 00:00:00 2001 From: Scott Noyes Date: Mon, 29 Nov 2021 09:51:31 -0600 Subject: [PATCH] avoid extraneous returned list The original version prints the desired values as a side effect of the list comprehension, and then produces an extraneous list of None values as the actual returned object. This version does away with that extraneous returned object, and prints the values purposefully rather than as a side effect. --- fizzBuzz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fizzBuzz.py b/fizzBuzz.py index ca276ce..578a09d 100644 --- a/fizzBuzz.py +++ b/fizzBuzz.py @@ -1 +1 @@ -[print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or i) for i in range(1, 21)] +print(*('Fizz'*(i%3==0) + 'Buzz'*(i%5==0) or i for i in range(1, 21)), sep='\n')