Question

Write a program in Python that finds the index of an item in a list. For...

Write a program in Python that finds the index of an item in a list.

For example:

You create a of list of colors

You find the index of the color "red"

Print the list and the index of "red"

Your program should work for every item in your list, and it must have at least 3 items in the list.

It must also work if you search for an item and it does not exist in the list. You should print a message saying the item does not exist in the list.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solved using the concept of lists in Python

Add a comment
Know the answer?
Add Answer to:
Write a program in Python that finds the index of an item in a list. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Provide Python code that does the following: Create the following list in your program: lst1 =...

    Provide Python code that does the following: Create the following list in your program: lst1 = ["apple", "banana", "pear", "grapefruit", "pineapple", "grape", "guava", "plum", "peach"] Write code that then does the following: Print the last item in the list. Print the first item in the list. Print all but the last three items in the list. Print the first, third, fifth etc. items of the list. Print the second, fourth, sixth etc. items of the list. Parts A- E should...

  • Write a Python program (remove_first_char.py) that removes the first character from each item in a list...

    Write a Python program (remove_first_char.py) that removes the first character from each item in a list of words. Sometimes, we come across an issue in which we require to delete the first character from each string, that we might have added by mistake and we need to extend this to the whole list. Having shorthands (like this program) to perform this particular job is always a plus. Your program should contain two functions: (1) remove_first(list): This function takes in a...

  • Write a Java program that will create a random list (array) randomize a  search item to be...

    Write a Java program that will create a random list (array) randomize a  search item to be found in the list sequentially search the array for that item. You must code the search and not use a search function. Display each comparison in the array; the element contents and the index. display whether the item was found or not. Now take that code and alter it to have two lists. Both lists randomize between 1 and 50. While traversing one list,...

  • This Python program will need to include the following items listed below. You are to customize your program and create the sequence in any order of your choice. Must include Python comments for each...

    This Python program will need to include the following items listed below. You are to customize your program and create the sequence in any order of your choice. Must include Python comments for each of the items shown below. Calculate a Percentage. For example, the discount percentage on a sale item. Use of 3 Constants. To be used for values that will not change throughout the life of the program. A Turtle Graphic Logo. This logo will be used to...

  • Write in c++ please Imagine you are writing a program to manage a shopping list. Each...

    Write in c++ please Imagine you are writing a program to manage a shopping list. Each shopping list item is represented by a string stored in a container. Your design requires a print function that prints out the contents of the shopping list Using a vector to hold the shopping list items, write a print function to print out the contents of a vector of strings. Test your print function with a main program that does the following: 1. Create...

  • This Python program will need to include the following items listed below. You are to customize...

    This Python program will need to include the following items listed below. You are to customize your program and create the sequence in any order of your choice. Write in simple code. Must include Python comments for each of the items show below. Calculate a Percentage. For example, the discount percentage on a sale item. Use of 3 Constants. To be used for values that will not change throughout the life of the program. A Turtle Graphic Logo. This logo...

  • Your friend is writing a Python program to randomly provide the user with an inspiring quote....

    Your friend is writing a Python program to randomly provide the user with an inspiring quote. Unfortunately, your friend is a terrible programmer, and you promised to help them with their program. Basically, there is a list of inspirational sayings in the code, and the program enters a loop and gives the user a random quote. The program is then supposed to ask the user if they want another quote. If they answer anything other than ‘y’ the program ends....

  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • *Use Java to create this program* For this assignment, you will be building a Favorite Songs...

    *Use Java to create this program* For this assignment, you will be building a Favorite Songs application. The application should have a list with the items displayed, a textbox for adding new items to the list, and four buttons: Add, Remove, Load, and Save. The Add button takes the contents of the text field (textbox) and adds the item in it to the list. Your code must trim the whitespace in front of or at the end of the input...

  • Python program - Write a Python program, in a file called sortList.py, which, given a list...

    Python program - Write a Python program, in a file called sortList.py, which, given a list of names, sorts the names into alphabetical order. Use a one dimensional array to hold the list of names. To do the sorting use a simple sorting algorithm that repeatedly takes an element from the unsorted list and puts it in alphabetical order within the same list. Initially the entire list is unsorted. As each element is placed in alphabetical order, the elements in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT