Write a program that prints the integers from 1 to 100 (inclusive) in one line of code, however

Viewed 2492

I am new to python and would like to write a program that prints the integers from 1 to 100 (inclusive) in 1 line using python, however:

  • For multiples of three, print shell (instead of the number)
  • For multiples of five, print fish (instead of the number)
  • For multiples of both three and five , print shellfish (instead of the 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 can make this source code into one line?

2 Answers
Related