For the FizzBuzz program, I got only fizz and buzz and fizzbuzz for the output, but no numbers...What did I do wrong? I cant seem to figure out the issue here. Here is my code: for i in range(1,101): s = str(i) if i % 3==0 or i % 5==0: s='' if i % 3==0: s=s+'FIZZ' if i % 5==0: s = s+'BUZZ' print s

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

For the FizzBuzz program, I got only fizz and buzz and fizzbuzz for the output, but no numbers...What did I do wrong? I cant seem to figure out the issue here. Here is my code: for i in range(1,101): s = str(i) if i % 3==0 or i % 5==0: s='' if i % 3==0: s=s+'FIZZ' if i % 5==0: s = s+'BUZZ' print s

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

when you enter your first if loop you are resetting the value of s to just be a blank line which effectively is dropping out your number from the beginning of the line
what should I have instead of s=''?
when your code hits s=str(i) the first time it sets s='1'. then you enter your if loop and have s='' which changes s='1' to s='' what your doing is called reinitializing a variable which is causing your original s to forget the '1'. btw the only reason im not outright telling you the fix is because problem solving/debugging is one of the most important skills for programming

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

thanks I appreciate it...Id rather learn the process that just be told the answer any day. Let me tinker with this a little longer.
so here is what I went with and it worked like a charm. Thanks again for your help: for i in range (1, 101): if i % 3 == 0 and i % 5 == 0: print 'FIZZBUZZ' elif i % 3 == 0: print 'FIZZ' elif i % 5 == 0: print 'BUZZ' else: print i
glad to see you got it worked out :D

Not the answer you are looking for?

Search for more explanations.

Ask your own question