Writing Code for FizzBuzz in a way it can be extended to check for more words without a hideous if then refactor that would be error prone and tedious.
Timestamps:
00:00 How can a FizzBuzz solution be the best
01:35 What is the FizzBuzz interview programming problem
01:57 Start of basic FizzBuzz code
06:00 Why the basic if else FizzBuzz code falls apart while adding another "Bang" word
10:10 Best extensible FizzBuzz algorithm on YouTube
11:46 Adding Bang into our FizzBuzz logic the easy way
13:55 Adding Foo into our algorithm for FOUR different multiples checks
15:00 Wrapping up discussion and outro
=== Code ===
modulo_list = [(3,"Fizz"),(5,"Buzz")]
for i in range(1,101):
print_string = ""
for mod in modulo_list:
if i % mod[0] == 0:
print_string += mod[1]
if print_string == "":
print(i)
else:
print(print_string)
===========
For more python and software development content from me please visit my blog at https://beapython.dev/ also subscribe to the channel! It's free and helps push me to make more experience based tutorials.
Auf dieser Seite können Sie das Online-Video BEST FizzBuzz Python Code on YouTube Because Extensibility Matters mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer BeAPythonDev 27 August 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 728 Mal angesehen und es wurde von 17 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!