Concatenating strings Zybooks Lab 2.1.2

Viewed 903

Write two statements to read in values for my_city followed by my_state. Do not provide a prompt. Assign log_entry with current_time, my_city, and my_state. Values should be separated by a space. Sample output for given program if my_city is Houston and my_state is Texas: 2014-07-26 02:12:18: Houston Texas Note: Do not write a prompt for the input values.

current_time = '2014-07-26 02:12:18:'
my_city = ''
my_state = ''
log_entry =

''' Your solution goes here '''

print(log_entry)

I've tried several solutions and it is only printing out the date and time. Since the date and time is given, I figured to concatenate the city and state strings then add them under log entry however it still only prints out the date. I can't enter the actual city and state because there is a back end test where Zybooks add a different city and state. Here is what I have tried so far.

concatenated_string = my_city + ' ' + my_state
log_entry = current_time + concatenated_string
1 Answers

Actually figured it out.

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