Assigning a variable in a for loop

So i am writing a program for practice and needed some help with a for loop, The program takes the amount of people buying, the amount being brought and then the total money being paid.

Once it takes this it outputs the price per item

What i would like to happen next is for the program to use the amount of people stored in "GroupNo" to output the question "How much money has Person 1 put in, How much has person 2 put in"........ etc until it gets to the amount the user inputed.

I know to get the loop to output the question the right amount of times, its a simple case of "for i in range (0, GroupNo)" but how do i get each answer to this question to be stored in a new variable each time it is asked

GroupNo = int(input("How many people are buying?"))
Gs = int(input("How many are you picking up?"))
Ps = int(input("How much money is being paid?"))
PPG = Ps / Gs
print ("Price per item is:" ,"£",PPG,)

def MainCalc():
    for i in range (0, GroupNo):
        int(input("How Much is person 1 paying:")) #This would increment up till it hits GroupNo
MainCalc()


Read more here: https://stackoverflow.com/questions/66343058/assigning-a-variable-in-a-for-loop

Content Attribution

This content was originally published by Atay Hassan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: