Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

Dave Angel davea at davea.name
Thu Sep 19 16:18:36 EDT 2013


On 19/9/2013 14:46, William Bryant wrote:

> the word 'def' has  squiggily lines but the program works fine. It says: Syntax Error: expected an indented block. - why?
>

The direct answer is that your terminal program must be broken.  it
should not use "squiggly lines" for any purposes.

But perhaps you're not seeing this in terminal, but in some text editor.
Better specify what that is.

As for the "Syntax Error..."   Better supply the entire traceback.  I
can't see how you consider that error message as "working."

> def restart():

Better give it a different name, since you're using this same name as a
local within the function.

>     print("""
>
>     ~~~~~~~~~~~~~~~~
>
>     Cacluation DONE!
>
>     ~~~~~~~~~~~~~~~~
>
>     """)
>     restart = input("\nEnter yes if you want to make a new list and no if you want to close the program (yes/no):  ")
>     restart

This line does nothing, as has been pointed out before in other
messages. of yours.  You're not printing it, assigning it to something,
calling it, or whatever.

>     if restart == "yes" or restart == "y" or restart == "new list":
>         print("You want make a new list...\n")
>         time.sleep(1)
>         NOS()

There's no such function.

>     elif restart == "no" or restart == "n" or restart == "close":
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         print("Goodbye!")
>         time.sleep(1)
>         quit()

No such function.

>     else:
>         print("type y or n")
>         time.sleep(0.5)
>         restart()

You're using recursion when a simple loop is called for.

-- 
DaveA





More information about the Python-list mailing list