954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using values in a text file

Hey everyone, I'm fairly new to python and have hit a brick wall in a program I'm writing. I need to read in a text file containing values (No problems here) the text file looks like this

10, .25, .26
12, .44, .34
4, .22, .56

The numbers 10, 12, and 4 are supposed to be index numbers where those are used to print 1-10, 1-12, and 1-4. I'm stuck on trying to use these values in the text file.

Anything at all would be helpful!

ssmokincamaro
Newbie Poster
7 posts since Feb 2010
Reputation Points: 10
Solved Threads: 1
 

You can look at this,for taking out values.

l = []
for i in open('your.txt'):
    l.append(i[0:2])
    
print l
l1 = l[0]
print l1

'''Out-->
['10', '12', '4,']
10
'''
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: