简体   繁体   English

如何从列表中取出特定数据并存储在单个变量中

[英]How do i take out specific data from my list and store in a individual variable

I have a list that look like this我有一个看起来像这样的列表

myList = [2,4,6,8]

I want to take out the specific element from the list and store it in another variable我想从列表中取出特定元素并将其存储在另一个变量中

a = myList[3]

print (a)

By right the answer should give me 6 but i do not understand why it keep giving me error.正确的答案应该给我6,但我不明白为什么它一直给我错误。

Could anyone help me out?谁能帮帮我?

Use:利用:

a = myList[2]

List elements are assigned indexes [0,1,2,....]列表元素被分配索引 [0,1,2,....]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何打印列表中的单个单词? - How do I print out individual words within my list? 如何从 PyQt5 中的几个文本框中获取信息,并将它们存储到它们自己的单个类中 - How do I take information from several text boxes in PyQt5, and store them to their own individual class 如何从返回的数据库中取出单个数据? - How to take out individual data from a returned database? 如何从用户那里获取输入,将其存储在一个空变量中并打印该变量? - How do I take input from a user, store it in an empty variable and print the variable? 我如何从列表中删除一个项目并将其存储到 python 中的变量中 - How do i remove an item from a list and store it into a variable in python 如何从 discord 获取用户输入并将其存储为变量以在方程式中使用? Discord.py - How do i take user input from discord and store it as a variable to use in an equation? Discord.py 如何将列表范围存储为变量? - How do I store the range of a list as a variable? 如何从我的列表中取出 x 和 y,以便我可以使用它来创建图表 - How to take out x and y from my list so I can use it to create a graph 写入CSV时,如何防止列表项分解为单个字符串? - how do I prevent my list items from being broken up into individual strings when writing to CSV? 如何从我的 json api 请求中取出这些特定信息? - How do I take out this certain information from my json api request?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM