completely beginner in coding here. So, I am trying to create a project in Python3 that calculates how much each person needs to pay from a shared credit card bill. My logic will be better demonstrated in the code below.
My main problem is that, with every input that comes, I want to give the person the possibility to ''stop inputing'', in case that the individual doesn't have any more values to add, so the program would now pass to the next person.
I though that maybe an if else statement would help me, but I am not sure how to use it in a way that a numeric input asks for the next input, or the ''X'' to stop the sequence and get to the next print automatically. I've got something similar to this:
print("While you have items, put their value, otherwise, insert X, for the next person to start its values.")
p1 = input('First item')
// if p1 != X:
// them I don't know how to continue.
p2 = input('Second item')
p3 = input('Third item')
p4 = input('Forth item')
p5 = input('Fifth item')
p6 = input('Sixty item')
print("Now the second person.")
m1 = input('First item)
m2 = input('Second item')
m3 = input('Third item')
m4 = input('Forth item')
m5 = input('Fifth item')
m6 = input('Sixty item')
I hope I could illustrate the idea, sorry about the mess. Thank you!
Aucun commentaire:
Enregistrer un commentaire