Last active
January 29, 2021 09:22
-
-
Save iqfareez/de94ca00cd0264f144e87d7fd05a9d46 to your computer and use it in GitHub Desktop.
Windows ping to Google using Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def main(): | |
while True: | |
# Input can be Y/N or small letter y/n or word like yes/no | |
response = input('Do ping? (y/n)\n>>> ') | |
response = response[0] # Get the first char | |
response = response.lower() # Convert to lower case | |
if response == 'y': | |
DoPing() | |
break | |
elif response == 'n': | |
print('\n:")\n') | |
break | |
else: | |
print('You didn\'t answer that question. Please re-enter value (y/n)') | |
continue | |
def DoPing(): | |
""" | |
Ping to Google | |
""" | |
os.system('ping www.google.com') | |
print('\nPing donde\n') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output: