Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: A Program that prints the numbers from 1 to 100 Date: Sat, 14 Nov 2015 12:49:51 -0500 Lines: 22 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de gXtTpnY1sv/bL6ZJFW5FggeAoWC8r+g0rDBRZYC8B0TA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'python': 0.10; '"write': 0.16; 'accordingly': 0.16; 'multiples': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'email addr:gmail.com>': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; '----': 0.27; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; 'prints': 0.29; 'subject:numbers': 0.29; 'subject:that': 0.29; 'print': 0.30; 'url:mailman': 0.30; 'solutions.': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'skip:& 20': 0.35; 'received:google.com': 0.35; 'could': 0.35; 'nov': 0.35; 'but': 0.36; 'instead': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'doing': 0.38; 'received:209': 0.38; 'google': 0.39; 'does': 0.39; 'subject:from': 0.39; 'subject:the': 0.39; 'url:mail': 0.40; '\xc2\xa0and': 0.84; 'to:none': 0.91; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=SHb7mmZ5bbea7i4YIQzm59JQilLGBIwFWIKzf/ghNMs=; b=Ly0VlVPAy+anOGJNeIe4PXSK/IrzAlC8IBjnO8MDI/XK2dZ+yaoJJrPAN66gmo7pGn 8qEH2E5XI+JGwP7mGszRKeDL76qLRvN1tFbCngI3hKYPy8dnv05/rS77mF7oRWXqsMfr 5S6lSjt1CPj+mnTJlOc6lVnDOpdb1YakTNWJ7ad/5EORCsSnZ9K83drPCLTXyAt9C9ib E9hJs6WkjwbgKrWN0h/zKAVsGom1hP7arcUZrytebaYW+YRXERmOS73GPHvExe7UYaNz iwvv77G0iGWSxHPpYCkSLl5jeEjd4j0sbaKhQv1+Bft/WumZkBmVcPE2v4yTfhDehRw3 h3QQ== X-Received: by 10.107.30.80 with SMTP id e77mr24113619ioe.180.1447523391530; Sat, 14 Nov 2015 09:49:51 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:98824 On Sat, Nov 14, 2015 at 12:34 PM, 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 ? > -- > https://mail.python.org/mailman/listinfo/python-list > You could google fizzbuzz and find lots of solutions. But, to give you a hint, use a for loop with range to get the numbers, use if n % 3 and n % 5 to pick out 3 and 5 multiples, print accordingly -- Joel Goldstick http://joelgoldstick.com/stats/birthdays