Issue with Python / pyglatin?


#1

Hi all! Very new to coding, so please be kind :slight_smile:

I have entered the code exactly how it looks in the "hints "section, but it seems to throw up a syntax error on the “and” (see screenshot:

Also, it’s asking if I accidentally deleted the variable, but as you can see, it’s right there… Is this a glitch, or am I doing something wrong?

Thanks!


#2

I would look at the syntax error message in the output window. Its more helpful in this case

Why do you have the and keyword there?


#3

Thanks! It’s part of the lesson they’ve asked me to add in? Further screenshot below:


See the left side - the syntax is to be added to check the word entered only contains letters. I was struggling with it, so hit the hint to see what is suggested, and I input the code exactly as they’ve asked (just changed the names etc).

Thanks again


#4

i wasn’t paying attention.

Yes, but the general syntax for a if condition is:

if condition(s):

after the condition(s) you have a colon. Multiple conditions can be achieved with and or or, but there should be a single colon (:) at the end of the condition

i also see what confused, a condition should be on a single line. If you want to put the condition of if over multiple lines, parentheses are required


#5

Ah fabulous, thank you! I missed that sneaky colon! This error’s been driving me mad for about an hour, and it looks like it’s fixed now!

Thanks :smiley:


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.