-2

I have a loop that creates a list of sentences and I want them to print like this (all on different lines) :

Hi my name is joe
Hi my name is Sally
Hi my name is Bert

But they are printing like this instead:

['Hi my name is joe', 'Hi my name is Sally', 'Hi my name is Bert']

I am not too great at python so I would like a simple answer please. My loop looks a little like this:

sentence = "Hi my name is " + random.choice(name)
if name not in list:
        list.append(sentence)
Random Davis
  • 6,662
  • 4
  • 14
  • 24
Chantal111
  • 13
  • 2
  • Please post your code and error message. – Jacques Gaudin May 26 '16 at 16:01
  • Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. [Minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) applies here. We cannot effectively help you until you post your code and accurately describe the problem. – Prune May 26 '16 at 16:04
  • There is no error messages, I typed my code in, but it didnt format correctly when I asked my question – Chantal111 May 26 '16 at 16:11

1 Answers1

2

If your list is like this:

list = ['Hi my name is joe', 'Hi my name is Sally', 'Hi my name is Bert']

You would then simply do this:

for a in list: print(a)

Which would output this:

Hi my name is joe
Hi my name is Sally
Hi my name is Bert
Random Davis
  • 6,662
  • 4
  • 14
  • 24