A Program that prints the numbers from 1 to 100

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Nov 14 13:25:04 EST 2015


On 14/11/2015 17:34, Cai Gengyang wrote:
> I want to write a program in Python that does this ----
>
> "Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz"."
>
> How do I go about doing it ?
>

This homework problem has been asked repeatedly over the years.  Just 
use your favourite search engine and there will be numerous answers. 
However if you actually want to learn you'll have to try writing your 
own code at some point, so see 
https://docs.python.org/3/library/functions.html#func-range and 
https://docs.python.org/3/library/stdtypes.html#index-14 operation "x % y".

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list