Python Forum
Write two statements to read in values for my_city followed by my_state. Assign log_e - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Write two statements to read in values for my_city followed by my_state. Assign log_e (/thread-4818.html)



Write two statements to read in values for my_city followed by my_state. Assign log_e - Eliteucantbeat - Sep-10-2017

You can't edit lines 1-4 and line 11. This is what I have:
current_time = '2014-07-26 02:12:18:'
my_city = ''
my_state = ''
log_entry = ''

my_city = input("")
my_state = input("")
log_entry = (current_time + my_city + my_state)


print(log_entry)
The output I get is:
Output:
2014-07-26 02:12:18:HoustonTexas
Expected output is:
Output:
2014-07-26 02:12:18: Houston Texas
Not sure how to get those spaces. I've tried using commas instead of + but then I just get this:
Output:
('2014-07-26 02:12:18:', 'Houston', 'Texas')
Also tried
my_city = input("")
my_state = input("")
log_entry = print(current_time , my_city , my_state)
but then I get this"
Output:
2014-07-26 02:12:18: Houston Texas None
help plz.


RE: Write two statements to read in values for my_city followed by my_state. Assign log_e - stranac - Sep-10-2017

One option is to manually add a space in between your data:
log_entry = current_time + ' ' + my_city + ' ' + my_state

A different (and better) solution would be to use string formatting:
log_entry = f'{current_time} {my_city} {my_state}'