I am trying to use a variable from a python list, but my code only returns the brackets of the list. Is there something I am doing wrong?
I have tried to remove the quotation marks, but that does not work either.
The list I want to retrieve values from:
date = [4, 1, 2000]
What I am doing:
print(date[0])
What it returns:
[
I was thinking that it does behave like this because maybe Python sees this as a string. However, while mapping and listing the list it still gives me the same error. Can somebody help me out?
If it is a list which I assume it is, it will work
date = [4, 1, 2000]
print(date[0])
#4
But if it is a string it won't work and show up what you saw
date = "[4, 1, 2000]"
print(date[0])
So check out the format of date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.