FOR Mini Project — Form Wannabe
The problem...
Every app has a form. Name. Age. Country. Email.
You fill it in, you submit, something happens.
You're not building a real form today. But you're closer than you think.
The idea!
A for loop can ask questions one at a time. Each iteration — a new field. Each answer — printed back immediately.
No list. No database. Just a loop, an input, and a print.
The setup
fields = "name age country".split()
print(fields) # ['name', 'age', 'country']
.split() separates the string into individual words. You'll learn what that bracket notation means in the Data Structures chapter. For now — it's just a sequence your loop can move through.
Your mission
Loop through the fields. Ask the user for each one. Print a summary at the end.
The solution
fields = "name age country".split()
for field in fields:
answer = input(f"Enter your {field}: ")
print(f"{field.capitalize()}: {answer}")
print("Thanks for your data.")
Test it
# Enter your name: Bull
# Name: Bull
# Enter your age: 25
# Age: 25
# Enter your country: Romania
# Country: Romania
# Thanks for your data.
What's really happening
The loop moves through three words — name, age, country. On each iteration, it asks for input and prints the answer immediately. Three fields. Three questions. One loop.
.capitalize() makes the first letter uppercase — so name becomes Name in the output.
Go further
- Add more fields —
"name age country city job".split() - Change the final message based on the number of fields answered — use a counter
- Print each field with its position using
enumerate()
What you should understand now
- A
forloop can drive an interactive sequence — one step at a time .split()turns a string into a sequence of words.capitalize()makes the first letter uppercase- You don't need to store everything — sometimes printing as you go is enough