I've been trying to make a takeaway directory of sorts that will allow you to search by type of food, rating, cost etc.
I have been having a bit of trouble getting more than one row to print. If I am searching for say Pizza, Slice of heaven will come up like this:
-Slice of Heaven,Pizza,4.1/5,01904 731377,
but what im aiming for is:
-Slice of Heaven,Pizza,4.1/5,01904 731377
-Salt and Pepper,Pizza,3.0/5,01904 733733
-Bodrum Pizza,Pizza,3.3/5,01904 673300
-Dominoes Pizza,Pizza,3.6/5,01904 690000
The csv file looks like this:
Name,Type of food,Rating,Phone Number,,,
Fish King Takeaway ,Fish and Chips/Chinese ,3.9/5,01904 659775,,,
Heworth Chinese ,Chinese,3.9/5,01904 415163,,,
Clifton Chinese,Chinese,2.8/5,01904 655025,,,
Jaipur Spice,Curry,4.1/5,01904 673550,,,
Lukes Takeaway,Pizza,4.7/5,01904 610011,,,
Efes Pizza,Pizza,3.6/5,01904 652210,,,
Jorvik Spice,Curry,4.3/5,01904 624040,,,
Lucky Dragon ,Chinese,3.0/5,01904 782002,,,
Salt and Pepper,Pizza,3.0/5,01904 733733,,,
Bodrum Pizza,Pizza,3.3/5,01904 673300,,,
Dominoes Pizza,Pizza,3.6/5,01904 690000,,,
Slice of Heaven,Pizza,4.1/5,01904 731377,,,
and this is my code:
import csv
import random
f = open('Takeaway finder/Takeaway.csv', 'r')
reader = csv.reader(f)
takeaway = {}
for row in reader:
takeaway[row[1]] = {'Name' :row[0],'Rating': row[2], 'Phone Number': row[3]}
choice = input("what do you fancy tonight?")
print(takeaway[choice])