Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def replace_vars(fname):
- try:
- f = open(fname,'r')
- new_lines = []
- for line in f:
- line_word = []
- word = line.split()
- for w in word:
- w = w.strip()
- if w.startswith('?'):
- w = w[1:]
- w = w.replace('_', ' ')
- if w[-1].isalpha == False:
- punc = w[-1]
- w = raw_input("Give me a " + w[:-1] + ":")
- w += punc
- else:
- w = raw_input("Give me a " + w + ":")
- line_word.append(w)
- new_lines.append(line_word)
- for line in new_lines:
- for word in line:
- print word + " ",
- print '\n',
- except IOError:
- print "I could not find a file name" + fname
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement