Range Over Built in Assembly Language
Based on the provided information, here’s the translated code and explanation in Python:
Here we use range
to sum the numbers in a list. Arrays work like this too.
range
on arrays and lists provides both the index and value for each entry. Above we didn’t need the index, so we ignored it with the blank identifier _
. Sometimes we actually want the indexes though.
range
on dictionaries iterates over key/value pairs.
range
can also iterate over just the keys of a dictionary.
range
on strings iterates over Unicode code points. The first value is the starting byte index of the character and the second the character itself.
To run the program, put the code in a .py
file and use python
to run it.