Managing exceptions in Python: Difference between revisions
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
<syntaxhighlight lang="python" line="1" > | <syntaxhighlight lang="python" line="1" > | ||
try: | |||
number = input("Enter a number ") | |||
print("Your number was: " + str(number)) | |||
except NameError: | |||
print("Please use a number.") | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 52: | Line 23: | ||
<references /> | <references /> | ||
[[Category:This information is incomplete]] | |||
[[Category:Python]] | |||
[[Category:Exceptions]] |
Revision as of 10:27, 10 March 2016
Introduction[edit]
The list type is a container that holds a number of other objects, in a given order. The list type implements the sequence protocol, and also allows you to add and remove objects from the sequence.[1]
Lists are a primitive data type, very, very helpful for storing and changing data.
Example of a function[edit]
try:
number = input("Enter a number ")
print("Your number was: " + str(number))
except NameError:
print("Please use a number.")
This example was swiped from the official Python documentation which you should read. [2]