-
-
Save Mohamed2del/b3abf4be9ad03bbff3871361949b37e3 to your computer and use it in GitHub Desktop.
fname = input("Enter file name: ") | |
try : | |
fh = open(fname) | |
except: | |
print('Cannot open the file ',fname ,'please try again') | |
quit() | |
for line in fh : | |
line = line.upper() | |
line = line.rstrip() | |
print(line) |
why it doesn't work(the path error")
Its because in Windows you have to set the path in the environment to make python work.
If the error is about the path, then while you where installing python in your system, there is an option to set the path,which automatically sets the path to the system. So you guys dont have to worry about it.
fname = input("Enter file name: ")
fh = open(fname)
try:
fh=open(fname)
except:
print("file not found")
for lx in fh:
lx=lx.strip()
ly=lx.upper()
print(ly)
my code is right , but it doesn't get correct path.
using PyCharm Community everything of my code is right , but autograders doesn't get correct path why?
how to sol this problem
`fname = input("Enter file name: ")
try :
fh = open(fname)
except:
print('Cannot open the file ',fname ,'please try again')
quit()
for line in fh:
fy = line.rstrip()
print(fy.upper())
`
my code is right , but it doesn't get correct path.
using PyCharm Community everything of my code is right , but autograders doesn't get correct path why?
how to sol this problem
Is your issue solved? if yes, can you let me know how?
fname = input('Enter file name: ')
fhandle = open(fname)
for lines in fhandle:
print(lines.upper().rstrip())
fname=input("Enter a file name")
fh=open(fname)
dh=fh.read( )
lx=dh.upper( )
ly=lx.rstrip( )
print (ly)
Use words.txt as the file name
file = input('enter file name:')
fname = 'words.txt'
try:
fhandle = open(fname)
except:
print('Cannot open the file ',fname ,'please try again')
quit()
for line in fhandle:
line = line.upper()
line = line.rstrip()
print(line)
fname = input("Enter file name: ")
fh = open(fname)
for line in fh:
line=line.rstrip()
line=line.upper()
print(line)
find the 100% working solution here!
https://gist.github.com/rehatpsingh/6d016cc328f3fd183dfe59d28c6a1973
nothing wrong with the codes... the problem is to input "words.txt" instead of "words"...
fname = input("Enter file name: ")
fh = open(fname)
read = fh.read()
print (read.upper().rstrip())
print(fh.read().rstrip().upper())
file = input('enter file name:')
fname = 'words.txt'
try:
fhandle = open(fname)
except:
print('Cannot open the file ',fname ,'please try again')
quit()
for line in fhandle:
line = line.upper()
line = line.rstrip()
print(line)
fname = input("Enter file name: ")
fh = open(fname,'r')
for li in fh:
rs=li.rstrip()
up=rs.upper()
print(up)
((or))
fname = input("Enter file name: ")
try:
fh = open(fname,'r')
except:
print('invalid file')
for li in fh:
rs=li.rstrip()
up=rs.upper()
print(up)
What is the file name
Use words.txt as the file name
fname = input("Enter file name: ")
try:
fh = open(fname,"r")
except:
print("Cannot open the file ",fname ,"please try again")
quit()
x = fh.read()
y = x.upper()
w = y.strip()
print(w)
i don't understand how can we use "line" in "for line in fh" if we didn't define what was "line" first.
the code works fine the problem is with the browser you're using, especially Chrome, not compatible 100% with the graded external tool.
fname = input("Enter file name: ")
fh = open(fname)
fr= fh.read()
fs=fr.rstrip()
print(fs.upper()
Use words.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
for line in fh:
line = line.rstrip()
print(line.upper())
Use words.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
dh=fh.read( )
lx=dh.upper( ).rstrip( )
print (lx)
fname = input("Enter file name: ")
fh = open(fname)
for line in fh:
print(line.rstrip().upper())
Write a program that prompts for a file name, then opens that file and reads through the file, looking for lines of the form:
X-DSPAM-Confidence: 0.8475
Count these lines and extract the floating point values from each of the lines and compute the average of those values and produce an output as shown below. Do not use the sum() function or a variable named sum in your solution.
Use words.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
#fh.upper()
for x in fh:
y=x.rstrip()
print(y.upper())
The best Answer
fname = input("Enter file name: ")
try :
fh = open(fname)
except:
print('Cannot open the file ',fname ,'please try again')
quit()
txt = fh.read().strip().upper()
print(txt)
fname = raw_input("Enter a file name: ")
try:
ffile = open(fname,'r')
for line in ffile:
print (line.upper())
print (line.strip())
except:
print ("This file was not found")
why it doesn't work(the path error")