#πŸ”’ I cant compute help me understand

44 messages Β· Page 1 of 1 (latest)

solid galleon
#

so i just did a practice test and i cant understand what was wrong with my code

i had
``python
print('Hello, world!')


```python 
def fizzBuzz(n):
  if n % 3 == 0 and n % 5 == 0:
    print("FizzBuzz)
  if n % 3 == 0 and n % 5 != 0:
    print("Fizz")
  if n % 5 == 0 and n % 3 != 0:
    print("Buzz")
  if n % 5 != 0 and n % 3 != 0:
      print("n")

and it failed and idk why or i cant understand why idk im too washed on the coding

final valveBOT
#

@solid galleon

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

copper charm
solid galleon
#

ill do it again and sned a screenshot

#

but it failed all test

copper charm
#

Can you show the screenshot?

solid galleon
#

this is what i get

#

this incomplete

copper charm
#

Are you sure that the if __name__ == "__main__" block is needed?

solid galleon
#

this the right one

solid galleon
copper charm
solid galleon
#

would you mind joining a vc while i screen share

#

?

#

if your ok with that

copper charm
#

sorry, I can't join voice chat now

solid galleon
#

ok ok

final valveBOT
copper charm
#

What do you mean by "this the right one"?

solid galleon
#

the first one had no output

#

cuz it had two fizz buzz def

solid galleon
#

which is what the want but it failed the test

copper charm
#

Maybe you're not supposed to take any input yourself? Maybe you're supposed to just write the fizzBuzz function?

#

try that (i.e. remove the if block and its body)

solid galleon
#

thats what i did

#

and to fix it i added for i in range (1, n+1): at the top and it passed

#

so i just confused

eager nacelle
#

Hello, just jumping in

#

The issues is that you have different if statements

#

It can lead to multiple prints

#

So you need to do elifs

#

Also, in the last print statement you are printing a string, not the variable n

solid galleon
#

hmmmmmmmm

#

i still dont get it but i understand the i f statement multiple prints part

#

ook

#

i understand

#

thank u guys lmao

eager nacelle
#

no

#

problem

#

πŸ™‚β€β†•οΈ

final valveBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.