Post
Python
Hi all,
I’m trying to make a list that begins with a variable and ends with an integer. So I tried writing ‘a+list’ but I found an error. Here, ‘a’ as an integer and thus I cannot use either extend or append. Can I get any suggestions that work in this case?
Posted on 24th April 2024
Now the purpose why you saw the error because you are utilizing the variable name as the list which is not supported in Python, Python has a few reserved keywords that can not be utilized as the variable name therefore instead of that, you should utilize the below-mentioned method:-
l = 6
abc_list = [3, 2, 1]
print([l] + abc_list)
STILL GOT QUERIES?