+ 3
I wrote following code but it didn't give any results. Can anyone tell me how should I modify it to give out my desired result?
Object-oriented-programming(class) https://code.sololearn.com/cQrQ169sqhz3/?ref=app https://code.sololearn.com/cQrQ169sqhz3/?ref=app
8 Réponses
+ 4
the last line:
move print to the left, on the same indentation as the if.
nice code by the way
+ 3
i just learned something from your code. I never used yield before. I probably should practice object oriented programming.
+ 3
Saeed Mozaffari i started on sololearn almost 2 years ago. First small things in python, then html, css and JS. Just for fun and to keep up with my students 😄
+ 3
Saeed, can you explain line 10?
I know it adds every number to the previous one. I don't get your logic! nice.
+ 3
Iman Rafi self.a = 0, self.b = 1. self.a + self.b = 0 + 1 = 1, 1+1 = 2, 1 + 2 = 3, 2 + 3 = 5, 3 + 5 = 8, ...
when i delete line 10 the code doesn't work.
+ 1
davy hermans Oh what a stupid i am . I didn't notice that obvious mistake. Thank you any way. Your codes are nicer than mine.😊
+ 1
davy hermans really? I'm so glad to hear that . I also should practice oop. To be honest, I have had not any experience in programming I just started lesrning a few months ago.
0
(self.a, self.b) = (self.b, self.a + self.b)
always consider slow-witted guys when writing codes 😁