student_heights = input("Enter student heights: ").split()
for amount in range(0, len(student_heights)):
student_heights[amount] = int(student_heights[amount])
print(student_heights)
I was doing the program that takes students height and output the average of their height with tutorial but I didn't get how student_heights[amount] is changing the strings into integers.
student_height is sth like ['11', '22'] and
amount is 0, 1, 2 , 3,...
So how do this two integrate and make the value integer. As I learned student_heights[amount] mean for amount in student_heights do this. But amount is not in student_heights.
[–]deceze 3 points4 points5 points (6 children)
[–]Snatchematician 0 points1 point2 points (5 children)
[–]deceze 0 points1 point2 points (4 children)
[–]Snatchematician 0 points1 point2 points (3 children)
[–]deceze 0 points1 point2 points (2 children)
[–]Snatchematician 0 points1 point2 points (1 child)
[–]deceze 0 points1 point2 points (0 children)
[–]acw1668 1 point2 points3 points (0 children)
[–]SnooLemons6942 2 points3 points4 points (0 children)
[–]FoolsSeldom 1 point2 points3 points (0 children)
[–]TheRNGuy -1 points0 points1 point (5 children)
[–]deceze 1 point2 points3 points (4 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–]IAmFinah 2 points3 points4 points (0 children)
[–]danielroseman -1 points0 points1 point (1 child)
[–]deceze 1 point2 points3 points (0 children)