Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
mohan Abdul
Courses Plus Student 1,453 Pointsworkshop challenge, python, how do write in one string factors for the number 3 and another string factors for the numbe
workshop challenge, python, how do write in one string factors for the number 3 and another string factors for the number 5. Also a string for number that are not factors of 3 and 5.
i am guessing it has something to do with the '%' symbol, but this symbol is used for the remainder of the division. 23/7= 3, but the remainder is % = 2.
or it has something to do with the * sign as that's multiplication.
mohan Abdul
Courses Plus Student 1,453 PointsSteven Parker heres the snapshot: https://w.trhou.se/jmogh1ha29 The draft version is below the finished in pound sign. (I tried double "//" division as factors have to be divisiable by the number in question and tried double "**" as number has to be mulitiples of the number in question). I would have never have guessed "==" as the video titled If, Else and Elif say double "==" is something equal to i.e equality. So it translates into - reminder (number), equality and infinity. which i dont really get, if you could put it into better words? I will appreciate that. By reminder I mean modulu "%". Equality as "==" and 0 as infinity.
mohan Abdul
Courses Plus Student 1,453 PointsSteven Parker https://w.trhou.se/0mnrv0m0ce, I deleted """if""" from line 11 it works and replaced """+""" with """and""" which also works fine. I don't really get why on line 11 it doesn't need a function word like "if", "print" or "len" for example as the the program reads the scripts from left to right starting at top. Or is it because it has a perin "()" around it reads it? /N. Speaking about the draft on line 24: my theory as to why it ignored the "elif" script, is as before i mentioned it reads from left to right starting from the top, if the user inputs a number thats both factors of 3 and 5 then it fullfils both "if" script and makes line 24 somehow redundant. /N As the line "elif" is an alternative branch the program doesn't need to walk down that path, as both prior "if" branches have been fulfilled. /N The other thing is i had to google the "==" thing for the code for factors, should i be disheartened that the double equal has't come to me in regards to code for factors?
1 Answer
Steven Parker
243,266 PointsYou're right, the remainder operator is very useful here. For example, if your number has "3" as a factor, then "number % 3" will be 0 (zero).
So with proper logic, you can determine if a number has 3 as a factor, or 5 as a factor, or both. (Hint: check for both first).
mohan Abdul
Courses Plus Student 1,453 Pointsthere are no hints, if there is a hints section could you please drop a link.
Steven Parker
243,266 PointsThere is no "hints section". The things I am telling you in my answer are hints.
Also, it's helpful if you provide a link to the page you are working with, and show any code you have so far.
Steven Parker
243,266 PointsIt sounds like you are describing the reason I hinted about testing for the "both" condition first.
You don't need to upload workspaces, just make a snapshot of your workspace and post the link to it here.
And the word "hashtag" applies to identifiers on social media. It's not used in programming. A "#" character is just a "hash" or "pound" symbol.
Steven Parker
243,266 PointsAfter seeing the snapshot, the code at the top is pretty close, the main issues are:
- when combining comparisons like on line 4, use the word "and" instead of the "+" symbol
- the "if" on line 11 is not needed, the "else" just before it does the job by itself
Steven Parker
243,266 PointsYou don't need line 11 at all, it doesn't do anything. The keyword "else" on line 10 does the whole job by running the code that follows only when the previous tests all fail.
And "==" is a basic test for equality, it's not just for factors.
And happy holidays!
mohan Abdul
Courses Plus Student 1,453 Pointsmohan Abdul
Courses Plus Student 1,453 PointsSteven Parker, Hi, thank you i have done a completed version that ran and at the bottom i done a draft version in hashtag in italic to show you. As i would like to talk about draft version that had glitches as any number divisiable by 3 & 5 would not print """ is a fizzbuzzer number"""". instead would print"""is a fizz number""" /n &"""is a buzz number""" and would ingnore the elif script at the bottom. (how do I upload the workspace into the post? along the file bar there is take a snap shot, preview and fork. which one would I have to select.) (thanks for the hint by the way i did have intial thought that i might have something to do with 0, as 0 can represent infinity. i tried double "//" division as factors have to be divisiable by the number in question and tried double "**" as number has to be mulitiples of the number in question) I would have never have guessed "==" as the video titled If,Else and Elif say double "==" is something equal to i.e equlity. . so i translates into - reminder (number) equlity and infinity. which i dont really get, if you could put it in better words i will apreciate that.