Published in

CodeX

# The FizzBuzz Problem

## Example Printout

`12fizz4buzzfizz78fizzbuzz11fizz1314fizzbuzz16…98fizzbuzz`

# Multiple Line Solution

`for x in range(1, 101):    if x%15 == 0:        print('fizzbuzz')    elif x%5 == 0:        print('buzz')    elif x%3 == 0:        print('fizz')    else:        print(x)`

# One line FizzBuzz Example

`print('\n'.join(['fizzbuzz' if x%15 == 0 else 'buzz' if x%5 == 0 else 'fizz' if x%3 == 0 else str(x) for x in range(1,101)]))`
`[x for x in range(1, 101)]`
`['fizzbuzz' if x%15==0 else x for x in range(1, 101)]`
`['fizzbuzz' if x%15==0 else "buzz" if x%5 == 0 else "fizz" if x%3 == 0 else x for x in range(1, 101)]`
`['fizzbuzz' if x%15==0 else "buzz" if x%5 == 0 else "fizz" if x%3 == 0 else str(x) for x in range(1, 101)]`
`'\n'.join(['fizzbuzz' if x%15==0 else "buzz" if x%5 == 0 else "fizz" if x%3 == 0 else str(x) for x in range(1, 101)])`
`print('\n'.join(['fizzbuzz' if x%15==0 else "buzz" if x%5 == 0 else "fizz" if x%3 == 0 else str(x) for x in range(1, 101)]))`

--

--