My Question .
I’ll ask with example so that anyone can understand it easily.
I made a list like
L1 = [aon,bird,asia,champ,den,derek,canada,india]
And now i want to take out an element from it starting with specific letter for example i need 1 element starting with ‘d’. And now what should i code that it brings output the 1 word starting with ‘d’ from that list?
My Question .
Sorry Sejan, I don’t understand your example.
You have a list like this:
L1 = ['aon', 'bird', 'asia', 'champ', 'den', 'derek', 'canada', 'india']
and you want a word starting with ‘d’. Which word do you want? The first
word, or the longest, or something else? Maybe all the words?
Do you want the word itself, or the position of the word? With the
position you can then delete the word if you want.
I’m going to guess you want something like this:
for position, word in enumerate(L1): if word.startswith('d'): print(word, position)
Does that help?
Respected sir,I also agree that this program is complicated and I am also searching this program for few months and I didn’t get anything. Now back to the question. So I want to make program I which user will randomly give any alphabet like ‘g’ and program will find the word starting with ‘g’ in the list if it exists then it will be printed but problem is coming it is giving all word starting with ‘g’ but I want only one. So, I hope understood my problem and will help me. And if you didn’t understand I will email you again.
I think you should show your code if you would like to understand why it’s not doing what you expect.