Why is this not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this not working?

I'm making this class, but it's saying that the arguments aren't defined! Why is this? https://code.sololearn.com/cQMVIWpSufyB/?ref=app

16th Sep 2022, 3:54 PM
MyNameIsNotBob
MyNameIsNotBob - avatar
4 Answers
+ 4
Have a look at lesson 73 of the Python core course. You haven't defined the properties and erroneously tried to inherit from non-existing nominator and deniminator classes
16th Sep 2022, 4:00 PM
Lisa
Lisa - avatar
+ 1
AJ 🇺🇦#PeaceForUkraine🇺🇦 Wrong syntax for class definition You cannot make class with arguments instead you have to make constructor of class With correction but there need some correction from your side Also float or int is not iterable so you have to convert in str ------- class Fraction: def __init__(self, numerator, denominator): self.numerator = numerator self.denominator = denominator def convertToDecimal (): decimal = numerator / denominator def simplify (self): i = 2 while ("." in (str(self.numerator / i))) or ("." in (str(self.denominator / i))): i += 1 if i > 500: print("Error: cannot simplify " + str(self.numerator) + "/" + str(self.denominator) + "!") newfraction = Fraction(100, 200) newfraction.simplify()
17th Sep 2022, 5:48 AM
A͢J
A͢J - avatar
0
Ok
16th Sep 2022, 7:20 PM
MyNameIsNotBob
MyNameIsNotBob - avatar
0
Thanks
17th Sep 2022, 12:08 PM
MyNameIsNotBob
MyNameIsNotBob - avatar