0

I'm trying write a program that keeps printing a random fish emoji from a list, and each time it does, it'll print an additional fish on the same line. For example, the first printed line will have 1 fish, then the next line will have 2, then 3, and so on.

I have this code so far:

import random
import time

#
#
#

fish = ['', '', ''];

while 1 == 1 :
    print(random.choice(fish));
    time.sleep(.1)

This prints a single fish per line. How can I make it print additional fish on the same line?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • 1
    If the linked duplicate does not answer the question (I inferred that the sticking point is in actually making things appear on the same line), then please start by thinking about the problem logically. Can you think of a rule that tells you how many fish should appear on this line? Can you think of a way to use, for example, a loop to print a specific number of fish? (If you know how to make things print on the same line, as in the linked duplicate, then this takes care of a single line of the desired output, right?) – Karl Knechtel Jan 01 '23 at 22:24
  • 1
    Can you think of a way to keep track of how many fish should be on a particular line - for example, by using a variable that stores how many fish are on the current line? Can you think of a way to use a loop, to repeat the "output one line" process and update the number of fish to use, and thus print all the lines? If your answer to any of my questions is "no", then **that is where your actual question is**; and we expect questions to be **focused and specific** like that here. On the other hand, if you do know how to do all of these things, then **what exactly is the difficulty**? – Karl Knechtel Jan 01 '23 at 22:26

0 Answers0