Python 3.10 Fizzbuzz

Thomas Passin list1 at tompassin.net
Mon Feb 27 11:08:22 EST 2023


On 2/27/2023 11:01 AM, Mats Wichmann wrote:
> 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.

I prefer single quotes because they are easier to type.



More information about the Python-list mailing list