Example code - Exceptions: Revision history

Jump to navigation Jump to search

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

1 March 2024

  • curprev 16:5416:54, 1 March 2024WikiSysop talk contribs 1,489 bytes +1,489 Created page with "== Determining input type == How to determine the input with try/expect. This is not really how it is done in practice, but it is still good to understand the ideas, because sooner or later you run into a situation where parts of this is useful. <pre> inputstring = input("Enter something and I will guess what it is: ") try: # This assignment will succeed mytype = 'string' # This may fail, in such case our exception handler is called result = float(inputst..."