Count the number of periods (.) there are in the file.
Use the built-in function count()
on the file after you have converted it
to a string.
Answer with the result as an integer.
I've no idea to do this..please help!
Count the number of periods (.) there are in the file.
Use the built-in function count()
on the file after you have converted it
to a string.
Answer with the result as an integer.
I've no idea to do this..please help!
try as follow
with open('file.txt') as f:
file_content = f.read()
result = file_content.count('.')
result
will be the number of periods.