I need help with my code

Hello i really need help on my code https://replit.com/@Nathanielcodes/DarkorangeDodgerblueRouter#main.py
please try and get back to me

Hi @Nathanielcodes

I moved your post into a new topic. Please explain in more detail what you need help with so others in the community can offer some ideas.

1 Like

Thank you for responding so basically what i am trying to do is it will ask for your age race birthday and name then after you put all that in it will ask if you want another record or like if you want it to ask you for name age race and it will do that four times then when you are done it will print that information.Thank you i know that was a lot

1 Like

Hi again,

I think you need to start by deciding how you are going to store the values once you have asked the user for each of them. I can see in your code that you are asking the user to enter information which is then saved in a variable, but if you loop this 4 times you will only be able to access the last piece of information entered.

I recommend looking into 1D parallel arrays or records (I teach use of @dataclass to create record structures). Once you have created the right structure you just need to loop around the first four lines of code and keep appending new information to the structure. Hope this helps!

1 Like

This is what my code looks like currently:

Name_enter = input("Enter name : ")
Age = int(input("Enter age : "))
Race = input("Enter race : ")
Birthday = int(input("Enter date of birth : "))
After = print("Would you like another record")
while After == "Yes":
	Cay = input("Enter name : ")
1 Like

You can format your code in the forum by putting ``` before and after the code block. Looks really nice when you do this.

1 Like

The last two lines of code will create an infinite loop, so watch out for that.

1 Like

Okay thank you this helps a lot


How would i loop the four lines of code with a while loop

1 Like

Why does it have to be a while loop? Can’t you use a for loop?

Here’s an example of each, so you can choose the best one:

counter = 0
while counter < 4:
    # do things
    counter = counter + 1
for counter in range(0,4):
    # do things

also can you explain the arrays and records and where i can get information to learn about it also how it will help my code
I recommend looking into 1D parallel arrays or records (I teach use of @dataclass to create record structures)

Hi @Nathanielcodes

Please take a look at some of the excellent online tutorials to learn more about this. I recommend Higher Computing Revision - Parallel Arrays as a starting point.

Okay,thank you a lot for the source last but not least how do i loop the first 4 lines of code do i use like a def function and last but not how is append gonna help me

1 Like

Re the loop I gave you two examples. The space where I wrote #do things should be where you put the first four lines.

Append is used to add new values to arrays, for example:

anArray = []
anArray.append("a value")
anArray.append("another value")

Will give you an array that looks like this:

["a value", "another value"]

Ohhh is that for me to print the values at the end or ask questions.