+ 2

Bug in Sololearn app??

So I’m trying to get past a python level, and I’m solving it but it says indentation error no matter what I do.. even did the stuck -> see solution and did exactly what it has for the solution. Here is the code def convert(num): if num ==0: return 0 return (num % 2 + 10 * convert(num // 2)) a=int(input()) print(convert(a)) It might have screwed up the indentation on this post but I’ve been stuck on it for about a month now. Can anyone help?

29th Sep 2024, 5:37 AM
Jack Douglas
Jack Douglas - avatar
14 Antworten
+ 5
Jack Douglas , as Bob_Li already mentioned is your code using 1 tab instead of only spaces: ... '=' = 61 '=' = 61 '0' = 48 ':' = 58 '\n' = 10 '\t' = 9 <<<< this is a tab ' ' = 32 ' ' = 32 ... it is in this line: ` return 0`
29th Sep 2024, 7:02 PM
Lothar
Lothar - avatar
+ 4
The problem you are facing this indentation because you are using unequal spaces between each indentation. All indentation should have equal number of spaces. I hope this helps. Happy coding !!
29th Sep 2024, 6:11 AM
Aysha
Aysha - avatar
+ 4
I had corrected the indentation and it was working fine. If it still not resolved. You can email to sololearn regarding this issue along the screenshot and details at info@sololearn.com
30th Sep 2024, 7:23 AM
Aysha
Aysha - avatar
+ 3
If you're unsure about indentation in python, then read this....... https://peps.python.org/pep-0008/
29th Sep 2024, 12:27 PM
Jan
Jan - avatar
+ 2
are you mixing tabs and spaces? or maybe typing the solution in some other ide and copy-pasting it here? What I usually do is to delete the indentations and re-indent them manually using the spacebar.
29th Sep 2024, 5:53 AM
Bob_Li
Bob_Li - avatar
+ 2
Jack Douglas , for indentation error, the compiler gives the number of the line where the issue appears. please check this. give us the error message. >> do you have any comments in the code file?
30th Sep 2024, 6:12 PM
Lothar
Lothar - avatar
+ 2
Thank you bob_li that worked!
1st Oct 2024, 1:57 AM
Jack Douglas
Jack Douglas - avatar
+ 2
Thank you everybody
1st Oct 2024, 1:58 AM
Jack Douglas
Jack Douglas - avatar
+ 2
Jack Douglas I just fired off a bunch of suggestions and hoped some of them would work...😅 Maybe a description of what actually worked? It would be a helpful guide for others with similar problems.
1st Oct 2024, 3:17 AM
Bob_Li
Bob_Li - avatar
0
Ive tried everything. Its the indentstion of this line return (num % 2 + 10 * convert(num // 2)) Ive manually added spaces, ive tried incorrect spacing. Nothing will pass this error.
30th Sep 2024, 7:01 AM
Jack Douglas
Jack Douglas - avatar
0
Its the python developer course, the recursion practice
30th Sep 2024, 7:06 AM
Jack Douglas
Jack Douglas - avatar
0
#Click on the three dots on the right of this reply, copy text and paste to the codebit editor . Maybe it's your keyboard or language setting that's adding non standard characters. Are you using the app or the web version?Does it happen to your other similar Python codes that use indentations? Lots of things to check that could give you clue on where the problem is. Or maybe a reload or update is necessary... def convert(num): if num==0: return 0 return (num % 2 + 10 * convert(num // 2)) print(convert(int(input())))
30th Sep 2024, 7:21 AM
Bob_Li
Bob_Li - avatar
0
Aysha please help me: Code to convert the value into a number JS let form = document.getElementById('form'); let currency = form.elements.currency.value; (currency);
30th Sep 2024, 2:16 PM
Sher Agha Hewadmal
0
Hi
1st Oct 2024, 2:23 AM
King ORTY
King ORTY - avatar