Summary: Program takes in 5 inputs from the user (1 string and 4 integers). For the exercise, I'm doing we need to convert the placing into points e.g. 1st place = 5pts, 2nd place = 3pts, 3rd place = 1pts, anything else = 0pts. Then the result will be printed out.
def calc_points(points):
for i in range(len(points)):
if points[i] == 1:
points[i] = 5
elif points[i] == 2:
points[i] = 3
elif points[i] == 3:
points[i] = 1
else:
points[i] = 0
return points
def get_place():
place = []
place.append(int(input("What place did you come in for your first race?\n> ")))
place.append(int(input("What place did you come in for your second race?\n> ")))
place.append(int(input("What place did you come in for your third race?\n> ")))
place.append(int(input("What place did you come in for your fourth race?\n> ")))
return place
def get_rider_info():
rider_info = []
rider_info.append(input("What is the Rider's Name?\n> "))
points = get_place()
total_points = sum(calc_points(points))
points.append(total_points)
rider_info.extend(points)
return rider_info
rider1 = get_rider_info()
print(rider1)
The problem is when the calc_points()
is executed the list points
changes e.g. input: Bob, 1, 2, 3, 4 Output: ['Bob', 5, 3, 1, 0, 9] when I want it to be ['Bob', 1, 2, 3, 4, 9].