0

Wrong Exercise Basic concepts Module I quiz

Hi, i want to post and let know about a wrong exercise, so the sololearn team can fix/change this. Exercise 3: What is the output of this code? >>> x = 5 >>> y = x + 3 >>> y = int(str(y) + "2") >>> print(y) The "correct" answer to this is 82. But its wrong, because in iine 3 variable "y" is reassigned to basically nothing.... If we do this in an interpreter the result will be: Traceback (most recent call last): File "..\Playground\", line 3, in <module> y=int(str(y)+"2") NameError: name 'y' is not defined

19th Jul 2017, 11:04 PM
Gabriel Leiva
Gabriel Leiva - avatar
2 odpowiedzi
+ 4
Copy paste and run the code in the playground x = 5 y = x + 3 y = int(str(y) + "2") print(y) # output 82 in line 3, y is simply assigned to a new value in the same way you can increment y by y = y + 1
20th Jul 2017, 2:30 AM
David Ashton
David Ashton - avatar
+ 3
Verified on Playground the result is 82, there is no problem with the quiz.
20th Jul 2017, 1:46 AM
Ipang