Inside the text file I currently have:
tickets = []
ticketPrice = 2.20
ticketsNo = 150
income = ticketPrice*ticketsNo
ticketHi = 54
limit = 1
winners = []
numbers = []
winningTickets = []
How would I now read the file and have it create variables and store values accordingly? I know about
with open("file.txt", "r") as f:
//do stuff
but I don't know how to implement it in the fashion I'm after. Thanks in advance
f.read().splitlines()to divide the file into a list of lines. Then split each individual line at the equal sign withsplit(' = '). You can then store the left-hand-side as the dictionary's key and the right-hand-side as the value. You can parse the constants usingeval(). Withincome = ticketPrice*ticketsNo, I'm not so sure...import myfile