Untitled
unknown
python
2 years ago
624 B
4
Indexable
def nalpha(): fp=open("sample.txt","r") na=0 s=fp.read() for i in s: if iisalpha: na+=1 fp.close(). print("No. of Alphabets:"‚na) def nwords( ): fp=open("sample.txt","r"') s=fp.readO 1-s.split() nw=len(1) fp.close() print("No. of words:"‚nw) def nlines(): fp=open("sample.txt","r") nl=0 1=fp.readlines0 get list nl=len(1) fp.close() print("No. of lines:"‚ni) while True: print("1: No. of alphabets ") print("2. No. of words ") print("3: No. of lines ") print("4: Exit"') ch=int(input("enter your choice:") if ch==1: nalpha() elif ch==2: nwords( ) elif ch==3: nlines( ) elif ch==4: break else: print("Invalid choice.")
Editor is loading...