I am using three lists to format something. However, when assigning values to the lists, I get this exception:
File "main.py", line 1
first-operand-list = ['', ' ', '3801', ' ', ' ', '123'];
^
SyntaxError: cannot assign to operator
Could anyone explain why? Here is the code:
first-operand-list = ['', ' ', '3801', ' ', ' ', '123'];
second-operator-list = ['', '- ', '2', ' ', '+ ', '49'];
line-list = ['------', ' ', '-----', ' '];
def to_result():
row_one = "".join(first_operand_list);
row_two = "".join(second_operand_list);
row_three = "".join(line_list);
math = row_one + '\n' + row_two + '\n' + row_three;
return math;
print(to_result());
Thank you.
>Solution :
Python doesn’t allow - in variable names. Use _ instead in first-operand-list and second-operator-list