You are viewing our Forum Archives. To view or take place in current topics click here.
Can someone help me with stacks in python?
Posted:

Can someone help me with stacks in python?Posted:

xLinz
  • Christmas!
Status: Offline
Joined: Jul 12, 20159Year Member
Posts: 103
Reputation Power: 15
Status: Offline
Joined: Jul 12, 20159Year Member
Posts: 103
Reputation Power: 15
Im trying to learn how to take the items I read from a .txt file, and add them to a stack(). Does this make sense? Can anyone help me?
#2. Posted:
Redacted
  • Blind Gifter
Status: Offline
Joined: Mar 02, 201410Year Member
Posts: 4,741
Reputation Power: 6053
Status: Offline
Joined: Mar 02, 201410Year Member
Posts: 4,741
Reputation Power: 6053
what's in the text file?
#3. Posted:
Skittle
  • Video King
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 201410Year Member
Posts: 6,813
Reputation Power: 413
What is it that you are unsure about? What to actually do with the contents of the file, or with the actual syntax of Python?
#4. Posted:
Xaldin
  • 2 Million
Status: Offline
Joined: Oct 09, 201014Year Member
Posts: 2,358
Reputation Power: 106
Status: Offline
Joined: Oct 09, 201014Year Member
Posts: 2,358
Reputation Power: 106
It makes sense but be specific about what you are having trouble understanding

I think you are looking for something like this?

 f = open('data.txt', 'r')
s = stack()
s.push(f.readline())
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.