-
-
Save rehatpsingh/6d016cc328f3fd183dfe59d28c6a1973 to your computer and use it in GitHub Desktop.
7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#100% working solution for python backgroud or python 3 | |
fname = input("Enter file name: ") | |
try: | |
fh = open(fname) | |
except: | |
print('file not found:error') | |
quit() | |
text=fh.read() | |
res=text.upper() | |
print(res.rstrip()) |
the codes are all fine. but where shall I store the file 'word.txt' with existing content? on my laptop or somewhere else?
thanks
You have to save the file "words.txt" with existing content on your laptop. it is weird that it did not work at the first couple of times. But after repeating trying a couple more times, it works out.
i am facing the same problem plz resolve it
have you solve it
have you solve it
Have you solve it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perfect code...Excellent