Range Over Built in R Programming Language

Based on the input provided, here is the translated code example and explanation in Python:

Let’s iterate over elements in a variety of built-in data structures. Let’s see how to use for loops with some of the data structures we’ve already learned.

# Here we use a for loop to sum the numbers in a list.
# Arrays work like this too.
nums = [2, 3, 4]
sum = 0
for num in nums:
    sum += num
print("sum:", sum)

# The for loop on lists provides both the index and value for each entry.
# Above we didn’t need the index, so we ignored it.
# Sometimes we actually want the indexes though.
for i, num in enumerate(nums):
    if num == 3:
        print("index:", i)

# The for loop on dictionaries iterates over key/value pairs.
kvs = {"a": "apple", "b": "banana"}
for k, v in kvs.items():
    print(f"{k} -> {v}")

# The for loop can also iterate over just the keys of a dictionary.
for k in kvs.keys():
    print("key:", k)

# The for loop on strings iterates over Unicode code points.
# The first value is the starting byte index of the character and 
# the second the character itself.
for i, c in enumerate("go"):
    print(i, c)

To run the program, save the code in a file (e.g., range_over_built_in_types.py) and use the python command.

$ python range_over_built_in_types.py
sum: 9
index: 1
a -> apple
b -> banana
key: a
key: b
0 g
1 o

This example demonstrates how to use for loops to iterate over lists, dictionaries, and strings in Python, allowing you to perform operations on each element or access their indices when needed.