repl.it
@JosephLooney/

Dictionaries

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#a dictionary is another data structure, it has a key and a value

words={"Ramen":"Asain Spaghetti","Spaghetti":"The foundation of the universe.","Sinjin":"A code stealer"}
print(words["Ramen"])

#add a word
words["Hotdog"]="Mystery meat log"
print(words["Hotdog"])

print(words)

#loop through the dictionary

for word in words:
	print(word,words[word])

prices={}
prices["bannana"]=4
prices["apple"]=2
prices["orange"]=1.5
prices["pear"]=3
prices["soul"]=10000000

print(prices)

stock={}
stock["bannana"]=6
stock["apple"]=0
stock["orange"]=32
stock["pear"]=15
stock["soul"]=7200000000

print(stock)

for food in prices:
	print(food)
	print("Price:",prices[food])
	print("Stock:",stock[food])

total=0
for i in prices:
	money=prices[i]*stock[i]
	print(money)
	total += money
print("The total amount of money you can make is: "+str(total))
Fetching token
?