So Im teaching myself how to program. So far I am going nowhere.
I have a code that from a line in a textfile, I put each word of that line in a list. Let's say the list is info =[john,guard,single]
. I have successfully loaded the words into the list but have some problems with my next task.
i want to get each word and use it in a sentence
all i have done so far is
for word in info:
print "My name is ",word[1]
print "My job is " ,word[2]
print "I am ",word[3]
but all i get is My name is o My job is h I am n can someone please help me?
ok so here's the code:
def loginfo(self):
infolist = []
with open('user.txt') as f:
f = f.readlines()
for line in f:
if str(self.neim.get()) in line:
if str(self.posse.get()) in line:
for word in line.split():
infolist.append(word)
for word in infolist:
print word[]