12th Nov 2017, 10:28 PM
Hamza Boudouche
7 Antworten
+ 8
You needlessly have put the happy() method inside print. The happy() method does not return anything, so there is no output. Lose the print and call the method directly. Also, the "break" line has to be indented a bit more, to be aligned with the print statement inside the while loop.
12th Nov 2017, 10:39 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
The call to happy() shouldn't be inside the call to print(), since happy() doesn't return any value, but prints from within the function. Also it looks like you mean for the break statement to be part of the if statement, in which case you need to indent it to match the indentation of the other statement in the if block.
12th Nov 2017, 10:41 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
change this line to add the brackets: x = sum([int(i)**2 for i in x])
12th Nov 2017, 10:47 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
[int(i)**2 for i in x] will make a list of the digits of the number input each of which is squared. if the user were to input "125" this would create a list like [1, 4, 25]
12th Nov 2017, 10:55 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
when I input 1 I get a "time limite eceeded" error
12th Nov 2017, 10:43 PM
Hamza Boudouche
0
I think the "break" statement isnt working
12th Nov 2017, 10:45 PM
Hamza Boudouche
0
@ChaoticDawg does this change anything
12th Nov 2017, 10:49 PM
Hamza Boudouche