Comparing file lines to strings in python, and inconsistencies
Question: Important things this code is supposed to in order of execution:

1.Open and read the file "Goods"

2.Assign a random line from file "Goods" to the dictionary "goods"

3.Go through an if block that will assign a random value to the dictionary
"cost" if goods[x] equals the string it's being compared to.

4.Print "goods", and "cost"

5.Repeat steps 2-4, 2 more times.

    
    
    from random import randint
    
    print("You search for things to buy in the market, and find:")
    f = open('Goods', 'r') #Opens file "Goods"
    lines = f.readlines() #Loads all lines from "Goods"
    goods = {1:"", 2:"", 3:""}
    cost = {1:"", 2:"", 3:""}
    x = 0
    while x < 3:
        x += 1
        goods[x] = lines[randint(0, 41)].strip()
    
    #Checks to see if goods[x] is equal to the string on the right, if it is, it assigns cost[x] to a random integer
        if goods[x] == "Lumber":
            cost[x] = randint(2, 3)
        elif goods[x] == "Rum":
            cost[x] == randint(3, 4)
        elif goods[x] == "Spices":
            cost[x] = randint(4, 5)
        elif goods[x] == "Fruit":
            cost[x] == randint(2, 4)
        elif goods[x] == "Opium":
            cost[x] == randint(1, 5)
    
    
        findings = '%s for %s gold.' %(goods[x], cost[x])
        print(findings)
    

The problem with this code is that the dictionary:"cost" does not get a value
assigned from the if block when goods[x] equals: Rum, Fruit, or Opium.

Could someone please tell me what's going on here?

[The file "Goods"](http://i.stack.imgur.com/SJpYE.png)


Answer: Your problem is that you are using two equal signs. `cost[x] == randint(3, 4)`
you need to use just one. Hope this helps!

