Python 3.10 Fizzbuzz

Mats Wichmann mats at wichmann.us
Mon Feb 27 11:01:26 EST 2023


On 2/26/23 14:07, Hen Hanna wrote:
> On Monday, August 29, 2022 at 7:18:22 PM UTC-7, Paul Rubin wrote:
>> Just because.
>>
>> from math import gcd
> 
>> def fizz(n: int) -> str:
>>         match gcd(n, 15):
>>                case 3: return "Fizz"
>>                case 5: return "Buzz"
>>                case 15: return "FizzBuzz"
>>                case _: return str(n)
>>
>> for i in range(1,101):
>>              print(fizz(i))
> 
> 
> is there any reason to prefer    "    over    '   ?

If you intend to run Black on your code to ensure consistent formatting, 
you may as well learn to prefer double quotes, because it's going to 
convert single to double (or: don't learn, and set your IDE to "convert 
on save" and don't think about it...)

As has already been mentioned, syntactically there is no difference.





More information about the Python-list mailing list