Ask coding questions

← Back to all posts
How do I fix my DEF error?
MatthewADev (18)

(NOTE: I'm not using REPL because it doesn't have the ping command, i'm using something else but it is python 3.8)
So i'm trying to create a simple IP pinger but i'm getting a error I never got before.

Answered by Coder100 (18185) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18185)

but if you want an empty function use pass

def ping():
  pass

doesn't seem like it but as a reference.

also nice solarized dark vscode (probably vscode)

MatthewADev (18)

@Coder100 It works, thanks :D! and i'm using google cloud shell :troll:

Coder100 (18185)

you forgot to indent!

def ping():
  hostname = h
  response = os.system("ping " + hostname)

lol

cuber1515 (57)

@2I9 what does the error say

cuber1515 (57)

Oh wait nvm. Ok so I might be wrong but I think you have to put async before def so it should look like this:

async def ping():
hostname = h
response = os.system("ping " + hostname)
MatthewADev (18)

didn't work D:
"invalid syntax" line 3

cuber1515 (57)

@2I9 ok. I realized someone else answered the question after I had already sent it btw.