Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. def replace_vars(fname):
  2.     try:
  3.         f = open(fname,'r')
  4.         new_lines = []
  5.         for line in f:
  6.             line_word = []
  7.             word = line.split()
  8.             for w in word:
  9.                 w = w.strip()
  10.                 if w.startswith('?'):
  11.                     w = w[1:]
  12.                     w = w.replace('_', ' ')
  13.                     w = raw_input("Give me a " + w + ":")
  14.                 line_word.append(w)
  15.             new_lines.append(line_word)
  16.         for line in new_lines:
  17.             for word in line:
  18.                 print word + " ",
  19.            
  20.     except IOError:
  21.         print "I could not find a file name" + fname
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement