0

I am creating an Enrollment Management Program as an output for our school.

The program I am creating contains a section that asks the user about their family.

One category is how many siblings they have. I want the program to ask the user for the number of siblings they have, and then execute the siblingCheck function that many times.

I tried this solution but it does not work, it continues to ask the user for the same values over and over again:

def siblingCheck():
    input("Name: ")
    input("Age: ")
    input("Grade Level: ")


siblingCount = int(input("Number of Siblings: "))
x = 0
while (x <= siblingCount):
    siblingCheck()
else:
    print("Next Section.")
1
  • add x+=1 after siblingCheck() to increment x; and use x=1 or while(x<siblingCount) Commented May 21, 2022 at 18:20

1 Answer 1

2

The trouble is that for any non-negative value of siblingCount, while loop will run forever. You may want use a for loop instead:

def siblingCheck():
    input("Name: ")
    input("Age: ")
    input("Grade Level: ")


siblingCount = int(input("Number of Siblings: "))
if siblingCount > 0:
    for i in range(siblingCount):
        siblingCheck()
else:
    print("Next Section.")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.