I have the following rule:
Create a function that receives a list of integers, and replace the items as below:
- If Multiple of 3 = 'Fizz'
- if multiple of 5 = 'Buzz'
- if multiple of 3 and 5 = 'Fizzbuzz'
I created the program below:
intList = list()
intList = [1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]
newlist=list()
def fizzbuzz( lista ):
for item in lista:
if item % 3 == 0 and item % 5 == 0:
lista.remove(item)
newlist.append(item) ='fizzbuzz'
elif item % 3 == 0:
lista.remove(item)
newlist.append(item) ='fizz'
elif item % 5 == 0:
lista.remove(item)
newlist.append(item)='buzz'
else:
newlist.append(item)=item
fizzbuzz(newlist)
But returns the following error:
C: \ Python27 \ my_scripts> for_loop.py File "C: \ Python27 \ my_scripts \ for_loop.py", line 15 newlist.append (item) = 'buzz' SyntaxError: can not assign to function call
Any idea what I can do? At the end of the program I need to list the integers and strings.
Thanks!