Ovi
Ovi

Reputation: 573

Opening text files

I have an assignment which involves extracting some information from a file. However, I'm not sure why it isn't working.

def main():
    print("Hello, this program will create a")
    print("bar graph showing the sales")
    print("\n\nSales Bar Graph")
    INFILE = open("sales.txt", "r")
    store1, store2, store3, store4, store5 = (INFILE.read()).split(", ")
    print(store1)

When I try to run this program, nothing happens.

Upvotes: 1

Views: 51

Answers (1)

TigerhawkT3
TigerhawkT3

Reputation: 49330

"Nothing happens" isn't technically true: your program defines a function called main. However, you never call that function, so its contents are never executed. Add a call to this function after defining it.

def main():
    ...

main()

Upvotes: 2

Related Questions