import sys import os from time import sleep def deleteDir( dir ): for name in os.listdir( dir ): file = dir + "/" + name if not os.path.isfile( file ) and os.path.isdir( file ): deleteDir( file ) else: os.remove( file ) os.rmdir( dir ) # enter script inputname = input( "what do you want to name the directory: " ) os.mkdir( inputname ) deleteit = input( 'A directory called ' + inputname + ' was created.\n\nDo you want to delete it? ' ) def maybeexit(): wanttoexit = input( "Do you want to exit: " ) if wanttoexit == "yes": input( "press any key to get 'outta here - script made by Lyle Davis... " ) raise SystemExit elif wanttoexit == "no": input( "Tough, you are. This program has no further use!" ) sleep( 1 ) input( "press any key to get 'outtta here - script made by lyle davis... " ) raise SystemExit else: maybeexit() if deleteit == "yes": deleteDir( inputname ); maybeexit() elif deleteit == "no": maybeexit() else: maybeexit()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question