Jul-18-2018, 07:32 PM
(This post was last modified: Jul-18-2018, 07:32 PM by MasterGame.)
I'm a Python 2 user and made a code to filter out the vowels in a phrase. This is the code:
filtered_phrase=open("vowel_filter.txt", "w") filtered_phrase_2=open("vowel_filter.txt", "r") vowel_filter=raw_input("Enter text: ") for char in vowel_filter: if char=="a" or char=="A" or char=="e" or char=="E" or char=="i" or char=="I" or char=="o" or char=="O" or char=="u" or char=="U": pass else: filtered_phrase.write(char) new_phrase=filtered_phrase_2.read() print new_phrase filtered_phrase.close() filtered_phrase_2.close()The weird part is, when I open vowel_filter.txt (the file that contains the altered phrase) the expected phrase is there, but when I attempt to read and print the file, it won't print anything. (I indented correctly the post just doesn't save the format)