string - I there a python function to reset the script after it's run? -
so when run in ide, terminal pops , input whatever, oututs way it's intended, terminal closes. there function can reset function in terminal same code in order keep entering things kind of game?
also there anyway me "<0" conditional work properly? need convert string number in order properly.
# rate our love!! ### press f5 ## input rating our relationship far print "type rating our relationship" love_rate = raw_input() ### word answers idk = 'idk' no = 'no' yes = 'yes' lol = 'lol' smh = 'smh' def love(n): if n < 0 : print "why negative?!" elif n == 'yes' : print " if that's case, think we're gonna fine." elif n == 'no' : print 'well then... awkward' elif n == 'lol' : print '''thats not number ......sniff''' elif n == 'smh' : print "i'm kinda mad that's answer thought of putting here" ## numbered entries elif n == '0' : print " *gasps profusely* don't deserve program" elif n == '1' : print "wow kinda hurtful, not gonna lie" elif n == '2' : print "you make me smile @ least once, each , every day" elif n == '3' : print"you wouldn't believe how annoying program run properly!" + " thats get?" elif n == '4' : print "let's " + "shoot little higher that" elif n == '5' : print "you're unforgettable, that's are" elif n == '6' : print "always have, '____' *hint* fill in blank " elif n == '7' : print "i never leave you, love much" elif n == '8' : print "an 8/10 still b, maybe i'm not trying hard enough" elif n == '9' : print " well, i'm not perfect yet, have seen 1 coming. guess have keep trying :)" elif n == '10' : print " think you're exaggerating, not yet" elif n == '11' : print """i can little immature , i'm sorry that, promise can better though. need you. need me out. can that?""" elif n == '12' : print "i don't think scale supposed go high" elif n == '13' : print "alright you're pushing it." elif n == '14' : print "alright, scale goes around 10. cease" elif n == '15' : print " go 1 more number. dare you" elif n == '16' : print " go 1 more number. see happens" elif n == '17' : print "one more number" elif n == '18' : print "one more" elif n == '19' : print "stop" elif n == '92412' : print " think 1 fantastic answer, can't wait our anniversary" else: print "i still hope married someday." def reset_print(): print """ wanna try again? :d """ love(love_rate) reset_print()
put in function , after finish script, can add yes or no question, if answer yes call function again.
import sys def myscript(): # rate our love!! ### press f5 ## input rating our relationship far print "type rating our relationship" love_rate = raw_input("type rating our relationship:") ### word answers idk = 'idk' no = 'no' yes = 'yes' lol = 'lol' smh = 'smh' love(love_rate) def love(n): if n < 0 : print "why negative?!" elif n == 'yes' : print " if that's case, think we're gonna fine." elif n == 'no' : print 'well then... awkward' elif n == 'lol' : print '''thats not number ......sniff''' elif n == 'smh' : print "i'm kinda mad that's answer thought of putting here" ## numbered entries elif n == '0' : print " *gasps profusely* don't deserve program" elif n == '1' : print "wow kinda hurtful, not gonna lie" elif n == '2' : print "you make me smile @ least once, each , every day" elif n == '3' : print"you wouldn't believe how annoying program run properly!" + " thats get?" elif n == '4' : print "let's " + "shoot little higher that" elif n == '5' : print "you're unforgettable, that's are" elif n == '6' : print "always have, '____' *hint* fill in blank " elif n == '7' : print "i never leave you, love much" elif n == '8' : print "an 8/10 still b, maybe i'm not trying hard enough" elif n == '9' : print " well, i'm not perfect yet, have seen 1 coming. guess have keep trying :)" elif n == '10' : print " think you're exaggerating, not yet" elif n == '11' : print """i can little immature , i'm sorry that, promise can better though. need you. need me out. can that?""" elif n == '12' : print "i don't think scale supposed go high" elif n == '13' : print "alright you're pushing it." elif n == '14' : print "alright, scale goes around 10. cease" elif n == '15' : print " go 1 more number. dare you" elif n == '16' : print " go 1 more number. see happens" elif n == '17' : print "one more number" elif n == '18' : print "one more" elif n == '19' : print "stop" elif n == '92412' : print " think 1 fantastic answer, can't wait our anniversary" else: print "i still hope married someday." print """want try again?""" yes = set(['yes','y', 'ye', '']) no = set(['no','n']) choice = raw_input().lower() if choice in yes: myscript() elif choice in no: sys.exit(0) else: sys.stdout.write("please respond 'yes' or 'no'") myscript() myscript()
Comments
Post a Comment