python:python-code
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| python:python-code [14/02/2025 10:40] – [CLI input selection for an option] andrew | python:python-code [14/02/2025 10:48] (current) – [Print both keys and values] andrew | ||
|---|---|---|---|
| Line 23: | Line 23: | ||
| - | ==== Print all the values ==== | + | ==== Print all the values |
| + | <code python> | ||
| + | exampledict = { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | for x in exampledict: | ||
| + | print(exampledict[x]) | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Modified Hall | ||
| + | Witherslack Hall | ||
| + | 1948 | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Print all the values - version 2 ==== | ||
| + | |||
| + | This uses the Python " | ||
| + | <code python> | ||
| + | exampledict = { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | for x in exampledict.values(): | ||
| + | print(x) | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Modified Hall | ||
| + | Witherslack Hall | ||
| + | 1948 | ||
| + | </ | ||
| ==== Print both keys and values ==== | ==== Print both keys and values ==== | ||
| + | Using the " | ||
| + | |||
| + | <code python> | ||
| + | exampledict = { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | for x,y in exampledict.items(): | ||
| + | print(x, y) | ||
| + | </ | ||
| + | < | ||
| + | class Modified Hall | ||
| + | engine Witherslack Hall | ||
| + | built 1948 | ||
| + | </ | ||
python/python-code.1739529638.txt.gz · Last modified: by andrew
