Special 0 - 100 list problem

how would you write a program which prints a list of numbers from 0 to 100, which replaces any number divisible by 3 with "x" string and numbers divisible by 5 with "y" string and numbers divisible by both with "x" + "y" string.

I have tried this:

x = 0 while x < 100: x = x + 1 print x if x % 3 == 0: print "X" elif x % 5 == 0: print "Y" elif x % 3 == 0 and x % 5 == 0: print "X" + "Y"

The code continues to print the integer along with the string and also the (elif x % 3 == 0 and x % 5 == 0: print "X" + "Y") does not work.

disclaimer: I am completley new to stackoverflow and programming in general.

Replay

Category: python Time: 2016-07-30 Views: 0
Tags: python

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.110 (s). 12 q(s)