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.
In questa pagina del sito puoi guardare il video online BEST FizzBuzz Python Code on YouTube Because Extensibility Matters della durata di ore minuti seconda in buona qualità , che l'utente ha caricato BeAPythonDev 27 agosto 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 728 volte e gli è piaciuto 17 spettatori. Buona visione!