Python Forum
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Somebody help pls!!
#3
Actually, I haven't tried lots of different variations, because I don't even know where to start :D We're having now the programming course in school and this have been the hardest one to me. So, I don't even know how I save information to txt file
:D

Oh, okay I have tried something like that and I think it works like how it should work. (This is a different exercise):

d = {}
products = int(input("How many products you want to save?: "))
for i in range(products):
    name = input("Input the name of the product: ")
    price = input("Input the price of the product: ")
    d[name] = price


print(d)

while True:
    name = input("\nInput the name of the product to see its price: ")
    if name in d:
        print("The price of the product is", name, d[name])
    else:
        print("The product doesn't exist.")

Oh okay, thanks! I'm noob with this website also, like with the Python :D I'll keep that in mind and don't do same mistake again.
Reply


Messages In This Thread
Somebody help pls!! - by pauliinaw - May-18-2020, 04:03 PM
RE: Somebody help pls!! - by Yoriz - May-18-2020, 04:08 PM
RE: Somebody help pls!! - by pauliinaw - May-18-2020, 04:14 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020