The original plan was to make the following text into an ultimate fizzbuzz one liner. I got as close to that as I possibly could, any ideas to make it smaller or cleaner?
#Ultimate FizzBuzz
def FizzBuzz(fin,code):
for i in range(1,fin+1): print(i, end = ' '),exec(code)
lst = []
code = ""
par = int(input("Enter how many parameters you have: "))
for i in range (0,par*2,2):
lst.extend([input("print: "),int(input("when its a multiple of: "))])
code = code + f"('{lst[i]}')*(i % {lst[i+1]} == 0)"+("+")*(((i+1)/par*2 == 1))
code = "print("+ code + ", end = '\n')"
FizzBuzz(int(input("till what number: ")),code)
The thing works just wanted to see how to make it smaller & cleaner
New contributor
Sotiris Ainatzis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3