Posted on 17th September 2024|50 views
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 17th September 2024| views
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)