forked from ARPIT443/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem6.py
More file actions
54 lines (43 loc) · 881 Bytes
/
problem6.py
File metadata and controls
54 lines (43 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
option = '''
Select operation you want to perform--->>
1.Show contents of single file :
2.Show contents of multiple file :
3.cat -n command :
4.cat -E command :
'''
print(option)
choice=input()
if choice == '1':
fname=input('Name of file :')
f=open(fname,'r')
print(f.read())
f.close()
elif choice == '2':
num=int(input('Enter no. of files :'))
fnames=[]
print('Enter name of files seperated by enter :')
for i in range(1,num+1):
name=input()
fnames.append(name)
for i in fnames:
f=open(i,'r')
print(f.read())
f.close()
elif choice == '3':
fname=input('Name of file :')
f=open(fname,'r')
data=f.read()
a=data.split('\n')
n=1
for i in a:
print(str(n)+' ' +i)
n=n+1
elif choice == '4':
fname=input('Name of file :')
f=open(fname,'r')
data=f.read()
a=data.split('\n')
for i in a:
print(i+'$')
else:
print('wrong input')