how do i extract a particular value from a variable's set of values

17 views
Skip to first unread message

Anthony Ezeh

unread,
May 2, 2020, 11:22:12 AM5/2/20
to spyder
is it possible to use something like the fetch funcion like in MATLAB to get a variable's value?

Lukas Wolfram

unread,
May 2, 2020, 9:35:38 PM5/2/20
to spyd...@googlegroups.com
Hey Anthony,

Depends on what you are working. 

Numpy offers where function or isclose function. Strings have the method find or index. Dict offer keys and values which give a list back in which you can search with the method index again. 

A = ["adg",1,34,6,89,"srhlo"]
A.index(1)
>>> 1
A.index(2)
>>> Error not in list

A[0].index("d")
>>> 1

Hope this is what you are looking for
Best regards
Lukas

On Sat, 2 May 2020, 17:22 Anthony Ezeh, <tony...@gmail.com> wrote:
is it possible to use something like the fetch funcion like in MATLAB to get a variable's value?

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/e74b85e4-5ca5-4566-b56a-5a91bd1e9756%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages