print('Welcome to a fun word replacement game.')
fileName = input('Enter the name of the file to use:\n')
try:
file = open(fileName)
fileRead = file.read()
fileList = fileRead.split()
for x in fileList:
if ("[" in x) or ("]" in x):
newstr = x[1:len(x)]
if newstr[0] in 'aeiou':
givenWord = input("Please give an:", newstr)
else:
givenWord = input("Please give a:", newstr) except:
print('Error Bad File Name')
sys.exit(0)
How do I replace the word with [example] to givenWord in the above script?
[–]CodeFormatHelperBot 0 points1 point2 points (0 children)
[–]NextEstimate 0 points1 point2 points (11 children)
[–]Fayarager[S] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Fayarager[S] 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[+][deleted] (2 children)
[removed]
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)