0
Help a noob
trying to write a code in m python and it's bringing a syntax error for the term print... spelling is 100% and I'm can't see why t wouldn't work. does anyone have any insight on this? is it because I'm using a phone to code this? https://code.sololearn.com/cBfyRIJPey9S/?ref=app
4 Respostas
+ 3
1st This line:
numbers = list(range(70)
is missing a closing ) for the list() function
numbers = list(range(70)) # <-- should look like this
2nd This line:
if{numbers(numbers % 3== 0)
Doesn't make sense at all. What are you trying to do here?
You're using a curly brace { which doesn't belong, and numbers is a list from 0 to 69
You can't modulus a list directly, but will need to get each element instead.
So if you can explain further it would be helpful.
+ 1
This is 1 way you can do this:
Note all numbers in this list range are a multiple of 3.
Change the list accordingly.
nums = list(range(3, 34, 3))
for i in range(len(nums)):
if nums[i] % 3 == 0:
nums[i] = "fizz"
print(nums)
0
I'm trying to program a list that takes multiples of 3 and replaces the numbers with the word fizz. apparently I got everything wrong apart from the he word fizz haha... thought I was being clever by using the link at function as opposed to define the numbers in a statement like "(numbers=0; numbers<70; numbers + 1)"
0
thanks, not exactly what I'm wanting to do but at least that's giving me an output haha.
I'm trying to get a list of numbers printed bit replacing every multiple of 3 with the word fizz. that's obviously still a *ahem* little out of my skill range ATM. also, learning python on the way to work and doing tutorials on JavaScript at work may not be the best idea.
seriously though, thanks for letting me waste your time. it means a lot