Q. Write a program that counts the number of characters up to the first $ in a text file.

Answer :-

file = open("pathwalla.txt","r")

data = file.read()
for i in range( len( data ) ):
    if data  [ i ] == "$" :
        break

print( "Total number of characters up to the first $ before = ",i )

Content in pathwalla.txt :-

This is Pathwalla website
here you can get all answer
Related to CS and $ IP
Ok3
Thank you

Output :-

Total number of characters up to the first $ before =  72
>>> 


6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post