-1

I am trying to print selected values from a list on one line in python 3.

Here is the code:

names = ['dog', 'house', 'in', 'is', 'the']
print (names [0])

prints result = dog

What I want to be able to do is to add list value index 2 so that the result would be = dog in. And that it prints on one line. I tried searching online and here but could not find a solution.

Dimitris Fasarakis Hilliard
  • 150,925
  • 31
  • 268
  • 253
roger
  • 23
  • 1
  • 5

1 Answers1

0

What you currently have is this:

names = ['dog', 'house', 'in', 'is', 'the']
print (names [0])

I believe what you are asking is that it will will print "dog in":

names = ['dog', 'house', 'in', 'is', 'the']
print (names [0], names[2])

Doing so will print both dog and in.

ethan lee
  • 172
  • 2
  • 13