PI. Function argument's default

Run Settings
LanguagePython
Language Version
Run Command
# If you want to set default value for function's argument, please behold the syntax. # It's pretty simple and understandible: def ask_ok(prompt, retries=4, complaint='Yes or no, please!'): while True: ok = raw_input(prompt) if ok in ('y', 'ye', 'yes'): return True if ok in ('n', 'no', 'nop', 'nope'): return False retries -= 1 if retries < 0: raise IOError('refusenik user') print complaint # The beauty is that if you have some values with default arguments, you're not # preaured to list them in the order of definition if you'd like to change one # or two values, just do it with the name. It would be described in more # details later. ask_ok('Should I learn Python?\n', complaint='Yes or yes!') # Because of technical reasons this example could not be run in the browser. # Use it as a copy-past to interpret somewhere else. # You can use: https://repl.it/
Editor Settings
Theme
Key bindings
Full width
Lines