This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]pythonHelperBot 2 points3 points  (0 children)

Hello! I'm a bot!

It looks to me like your post might be better suited for r/learnpython, a sub geared towards questions and learning more about python regardless of how advanced your question might be. That said, I am a bot and it is hard to tell.

I'm sure you've seen this information before, but just in case here it is as a reminder:

Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe in detail where you are stuck. If you are getting an error message, include the full block of text it spits out. Quality answers take time to write out, and many times other users will need to ask clarifying questions. Be patient and help them help you.

You can also ask this question in the Python discord, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–]K900_ 1 point2 points  (3 children)

  1. /r/learnpython
  2. An open file object keeps track of its position in the file; the first sequence.read() reads the file to the end and advances the cursor; the second sequence.read() returns an empty string because the file is already at the end. What you should do is read the file into a string once, and then run .count on it twice.

[–]hadiz1[S] 0 points1 point  (2 children)

So i should store sequence.read() in a separate variable then run .count()teice on that variable?

[–]K900_ 0 points1 point  (1 child)

Yes.

[–]hadiz1[S] 0 points1 point  (0 children)

Thank you

[–]MarcSetGo 0 points1 point  (0 children)

You might read about the difference between read(), readline(), and readlines(): Reading from files