0

I want to search an array for a string and get its index number.

li = ["New Year's Day", 'Lohri', 'Pongal', 'Makar Sankranti', 'Guru Govind Singh Jayanti', 'Republic Day', 'Chinese New Year', "Valentine's Day", 'Vasant Panchami', 'Shivaji Jayanti']

So what should I write to make it return the index number
like I call a faction check = checkindex('Pongal') and this should return 2. How do I write this function.

1
  • 1
    you mean list. In which case, just li.index(word) Commented Jul 2, 2021 at 3:25

1 Answer 1

2

You don't need a separate function for that

li.index('Pongal')
Sign up to request clarification or add additional context in comments.

1 Comment

i am new to python. Thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.