-1

I am trying to get this output: 2014-07-26 02:12:18: Houston Texas

When I try to do the assignment using:

current_time = '2014-07-26 02:12:18:'
my_city = 'Houston'
my_state = 'Texas'
log_entry = current_time + my_city +  my_state
print(log_entry)

I am getting this output: 2014-07-26 02:12:18:HoustonTexas

How do I get the spaces between the :, Houston, and Texas

Jeremy Defett
  • 21
  • 1
  • 1

2 Answers2

0

Work them in as string literals in your concatenation:

current_time = '2014-07-26 02:12:18:'
my_city = 'Houston'
my_state = 'Texas'
log_entry = current_time + ' ' + my_city + ' ' + my_state
print(log_entry)

Repl.it

esqew
  • 42,425
  • 27
  • 92
  • 132
0

You can just add them explicitly thing + " " + otherthing. Or you could use the " ".join method above if you know how to get your variables into a list.

Simon Notley
  • 2,070
  • 3
  • 12
  • 18