This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| scripting:python [2024/09/24 05:32] – jotasandoku | scripting:python [2024/12/23 13:46] (current) – S jotasandoku | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| netsim.cli.lab_commands(__file__) | netsim.cli.lab_commands(__file__) | ||
| + | '' | ||
| + | |||
| + | * Inside netsim/ | ||
| + | * we have the function '' | ||
| + | * the standard module '' | ||
| ---- | ---- | ||
| Line 325: | Line 330: | ||
| """ | """ | ||
| \\ | \\ | ||
| - | Slicing lists\\ | + | == SLICING === |
| - | print namelist[:2] | + | |
| + | # [:2] - First 2 elements | ||
| + | print("[:2] ->", | ||
| + | |||
| + | # [2:] - Everything from index 2 onwards | ||
| + | print(" | ||
| + | |||
| + | # [-2:] - Last 2 elements | ||
| + | print(" | ||
| + | |||
| + | # [:-2] - Everything EXCEPT last 2 elements | ||
| + | print(" | ||
| + | |||
| + | |||
| + | |||
| \\ | \\ | ||
| Updating list | Updating list | ||