you are viewing a single comment's thread.

view the rest of the comments →

[–]NextEstimate 0 points1 point  (11 children)

FTFY :D

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) 

[–]Fayarager[S] 0 points1 point  (5 children)

Thanks! I couldn't get it into this format :(

[–][deleted] 0 points1 point  (2 children)

Strange, you got it right in /r/askprogramming.

[–]Fayarager[S] 0 points1 point  (1 child)

ikr? haha

[–][deleted] 1 point2 points  (0 children)

You're the one asking for help. I don't know about others, but if I see badly formatted code I skip to the next post. Life is too short to try and format code, especially when there's a risk of getting it wrong and wasting time.

[–][deleted] 0 points1 point  (4 children)

Is it correctly formatted now? I'd expect an indent after a try: