Ask Your Question
0

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

asked 2018-03-30 11:39:59 +0100

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 16:35:00 +0100

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-10 06:31:38 +0100 )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 11:39:59 +0100

Seen: 2,312 times

Last updated: Mar 30 '18