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:
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:
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?
- 0useful
- 0not useful
#3. Posted:
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?
- 0useful
- 0not useful
#4. Posted:
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?
I think you are looking for something like this?
f = open('data.txt', 'r')
s = stack()
s.push(f.readline())
- 1useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.