Please help

HI i am trying to create a chat bot that asks for a certain price point and lists products inside that price point. however i am unsure how to do this. can anyone help.

price = input(f’do you have a specific price point for {product}s ‘)
price == int(price)
prices = {
“rockymountianslayer” : int(1000),
“norcostorm” : int(3000),
“yetisb165” : int(11000),
“yetisb100” : int(4070)
}
mountainbikes = [“rockymountianslayer”,“norcostorm”,“yetisb165”,“yetisb100”]
print(f’{mountainbikes}’)

i believe this part is the problem.

for prices > price:
mountainbikes.remove()
print (f’{mountainbikes}’)

When writing literals we don’t need to define them with a constructor.

rockymountainslayer: 1000,

Still reading…

Your second line is performing a comparison, when you want an assignment. Change == to =.

hi, i am still a bit unsure as it comes up as an error in this section
for prices > price:
mountainbikes.remove()
print (f’{mountainbikes}’)

for is an iterator when enabled by an __iter__ attribute on an object. When given an iterable, it iterates it.

for object in iterable:

object in this case will be the item at some location within the iterable. That item could be any object, proper; it just happens to reside at that location.

We are not saying, “for any price in prices greater than the price_point,” as your expression suggests.

thanks do you have any idea what the correct code should be?

Isn’t this your chatbot? We can point out the pot holes but does that suggest we will repair them, also?

2 Likes

I suggest you do a bit of reading on how to iterate through a dictionary. Reading the section Iterating Through .items() at https://realpython.com/iterate-through-dictionary-python/ should help. If you still need help after reading through that, let us know.

Thanks i think this may be correct.
output =
for i in mountainbikes:
if prices[i] < price:
output.append(i)
print(output)

i is not an index.

for i, x in enumerate(mountainbikes):
    if prices[i] <= price:
        output.append(x)