Thursday, 18 June 2020

Files with Exception handling

#Ask the user to take two input integer values var a,b

try:

    a=int(input("enter any integer value:"))

    b=int(input("enter any integer value:"))

    f=open("knl.txt","w")

    c=a/b

    print(c)

    f.write("writing %d in knl file" %c)

    #creating a new file name:knl.txt

   

except ZeroDivisionError:

    print("Please give other than zero for b")

finally:

    f.close()


x

6 comments:

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...