Question: I want to store all the "o"'s printed by stdout.write function into a a variable which could be accesable any time

I have tried using len function to break loop once it reaches certain amount of strings, but no luck

```
import time
import sys

while True:
    sys.stdout.write("o")
    sys.stdout.flush()
    time.sleep(0.05)

```

Answer: 
Very simply, you can add them to a string, one at a time:

```
record = ""
while True:
    sys.stdout.write("o")
    sys.stdout.flush()
    record += 'o'
    time.sleep(0.05)

```

A slightly faster way is to count the quantity written, and then produce your desired string:

```
count = 0
while True:
    sys.stdout.write("o")
    sys.stdout.flush()
    count += 1
    time.sleep(0.05)
    # Insert your exit condition

record = 'o' * count

```
Keep on appending values to a string. Check the length and break when desired.

```
import time
import sys

data = ""
while True:
    temp = "o"
    data += temp
    sys.stdout.write(temp)
    sys.stdout.flush()
    time.sleep(0.05)
    if(len(data)==10):
        break;

```