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
  • Challenger
Status: Offline
Joined: Jul 12, 20158Year Member
Posts: 103
Reputation Power: 15
Status: Offline
Joined: Jul 12, 20158Year 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
  • Gold Member
Status: Offline
Joined: Mar 02, 201410Year Member
Posts: 4,727
Reputation Power: 5977
Status: Offline
Joined: Mar 02, 201410Year Member
Posts: 4,727
Reputation Power: 5977
what's in the text file?
#3. Posted:
Skittle
  • Download King
Status: Offline
Joined: Aug 20, 20149Year Member
Posts: 6,813
Reputation Power: 413
Status: Offline
Joined: Aug 20, 20149Year 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, 201013Year Member
Posts: 2,358
Reputation Power: 106
Status: Offline
Joined: Oct 09, 201013Year 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.