Skip to content

Instantly share code, notes, and snippets.

@rehatpsingh
Created October 28, 2020 09:14
Show Gist options
  • Save rehatpsingh/6d016cc328f3fd183dfe59d28c6a1973 to your computer and use it in GitHub Desktop.
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.
#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())
@deepthishastry1425
Copy link

Perfect code...Excellent

image

@FibonacciB
Copy link

the codes are all fine. but where shall I store the file 'word.txt' with existing content? on my laptop or somewhere else?
thanks

@yingzhang0897
Copy link

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.

@lazurs1
Copy link

lazurs1 commented Aug 23, 2022

Nope
image

Copy link

ghost commented Jul 28, 2023

i am facing the same problem plz resolve it

Copy link

ghost commented Jul 28, 2023

have you solve it

@AlQataberi
Copy link

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