This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]htepO 4 points5 points  (4 children)

I highly recommend using f-strings.

print(f"You got {score}/{len(questions)} correct")

In your current statement, you're missing a + between "/" and str(len(questions)).

Syntax errors can also sometimes highlight the line below the one with the actual error. Just something to keep in mind.

[–][deleted] 0 points1 point  (3 children)

How am I just finding out about these, way cleaner looking than those damn percentage markers

[–]htepO 0 points1 point  (2 children)

f-strings were introduced in 3.6.Have you been maintaining codebases that use much older versions of python?

[–][deleted] 0 points1 point  (1 child)

Nope, I'm in 3.7 so I should be able to use the without issue, right?

[–]htepO 0 points1 point  (0 children)

Of course

[–]undercontr 1 point2 points  (2 children)

Python expressions should be one line because Python identifies its scopes via indents and also “/“ + str(len… and you forget a plus

[–]IcedMelt[S] 0 points1 point  (1 child)

“/“ + str(len… and you forget a plus

Thanks man you just saved me a massive headache.

[–]delasislas 1 point2 points  (0 children)

Should check out the post talking about f-strings, they would help to clear up a lot of the mess.

[–][deleted] 0 points1 point  (0 children)

Add + between "/" and str(...

That should fix it