Did you type out that code yourself or did you copy and paste it from somewhere else?
Because the issue that you seem to be facing is most likely because of copying and pasting code from somewhere else.
In your for loop, as you can see, the code lines (10 - 12) are indented. Those indentations can either be added by pressing the space bar four times, our by using the Tab key.
Unfortunately, depending on the interface you are using, those 4 space bar presses, and the ` Tab key, are not equivalent in Python. And that can lead to the kind of error you got. This is common when you copy-paste code from somewhere else.
So, I would recommend that you
remove that code,
type out the code yourself,
make sure you either indent using either just the space bar or just the Tab key,
and try again. Because I just tried the code you share above, and didn’t get the same error.
I would also recommend removing the space between row and [-1]
Yes, i typed the code myself, but the identation at line (10-12) came by itself when I clicked on enter key after line 9.
I have carefully deleted the identation space in line (10-12) and I put the space myself by clicking the space-key 4 times but I still got another error which is syntax error.
While the platform is completely functional on a device like a smartphone, the web app was designed, first and foremost, with the desktop experience in mind, in order to simulate a real-world DA/DS workflow. This means that there are things that are less than optimal on a smartphone, like the size of the coding window, and having to use the virtual keyboard to code.
Mobile/Tablet keyboards use curly quotes instead of straight quotes. This image shows the difference.
The python interpreter doesn’t accept curved quotes for representing string values. So you may get SyntaxError: invalid character in identifier when using a mobile device.
Even though your code may appear to be exact as the solution, there might be an invisible character like zero-width space which could be the cause of this problem. This typically happens when we access the platform using mobile.
I hope this helps! I recommend you to use a desktop/laptop to use our platform.
If you don’t have access to a desktop/laptop, then here is a way to solve this issue (not guaranteed):
Notice the ^ character in your error. This indicates that there is an invalid character (Probably zero-width space) somewhere around the rating variable. Place your text cursor on the left side of r. Hit backspace until the text cursor reaches the : character in the previous line. Now hit enter and run your code.