r/PythonLearning • u/Several_Goal4568 • Jun 11 '26
Discussion Biginner python project
items=\["milk","cheese","meat"\]
prices=\[10,100,230\]
for i in range(len(items)) :
print(f" {items\[i\]} - {prices\[i\]}")
ask=int(input("how many items do you wants to buy :"))
pick=\[\]
total=0
for n in range(ask) :
item=input("what item do you wants :")
pick.append(item)
position=items.index(item)
price=prices\[position\]
total+=price
print(total)
2
u/drakhan2002 Jun 11 '26
A great beginner project is a "spell checker". YOU'D be surprised how often you would use it.
0
u/Several_Goal4568 Jun 12 '26
A spell checker , hmmm great project, but user can input any word would have to make this into a guessing game where the user would name dairy products if spelling right will print your spelling is right something like this , or else not right.
This is the thing that got in my mind by after reading your comment.
4
u/Special-Arrival6717 Jun 11 '26 edited Jun 11 '26
I would advise using dict objects to track the data of individual items, and not create a separate list for each field of an item, e.g.
items = [
{
"name": "milk"
"price: 10
}
]1
u/csabinho Jun 11 '26
By objects you mean a list of dicts. An object would be an instance of a class, which is way above OP's knowledge.
1
u/Special-Arrival6717 Jun 11 '26
In Python a
dictis an object, an instance of thedictclass.print(isinstance({}, object)) # True1
u/csabinho Jun 11 '26
In Python every variable, value or function is an object. You won't find anything that returns False for this check. Even a function or None are objects with this check.
2
•
u/Sea-Ad7805 Jun 11 '26
Run the properly indented version of this program in Memory Graph Web Debugger to see the state of the program change step by step.