Write a program that prints integers from 1 to 100 (inclusive) in one line of code, however
I am new to python and would like to write a program that prints integers from 1 to 100 (inclusive) on 1 line using python, however:
- For multiples of three, type
shell
(instead of number) - For multiples of five, type
fish
(instead of number) - For multiples of both three and five, type
shellfish
(instead of number)
I can do this, but not in one line of code, unfortunately:
for i in xrange(1, 101):
if i % 15 == 0:
print "shellfish"
elif i % 3 == 0:
print "shell"
elif i % 5 == 0:
print "fish"
else:
print i
How do I make this source code in one line?
+3
source to share
2 answers