Ask Your Question
0

Is there a command to find the place of an element in an array?

asked 2018-03-30 04:39:59 -0600

logomath gravatar image

For example, let v=[a, b, c, d] I wonder if there is already encoded a function f such that f(a)=0, f(b)=1, f(c)=2..

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-03-30 09:35:00 -0600

B r u n o gravatar image

You can use v.index(a) to get the index of the first occurrence of a. An exception is raised if a is not in v.

edit flag offensive delete link more

Comments

Tank you very much

logomath gravatar imagelogomath ( 2018-04-09 23:31:38 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-03-30 04:39:59 -0600

Seen: 46 times

Last updated: Mar 30