3.7.3.1. Exercise: Looping using for and range 1#

A therapist measures a patient’s maximal shoulder flexion angle three times. Write a program that creates a list of these three measurements based on user input, following this example:

Example of program output

Enter max shoulder flexion (deg) [measurement 1]: <User enters 119>
Enter max shoulder flexion (deg) [measurement 2]: <User enters 124>
Enter max shoulder flexion (deg) [measurement 3]: <User enters 123>
Max shoulder flexion: [119.0, 124.0, 123.0]
# Initialize an empty list of measurements
measurements = []

# Ask the values
for i in range(3):
    str_value = input(
        f"Enter max shoulder flexion (deg) [measurement {i}]: "
    )
    measurements.append(float(str_value))

# Print the result
print("Max shoulder flexion:", measurements)