
IN python
Given a list and an integer, determine if that integer is "everywhere" in the list. We define a value as being "everywhere" if, for every pair of adjacent elements in the list, at least one element in the pair is that value. Return true if the given value is "everywhere" in the list. Otherwise, return false.
The first input is the comma delimited string (use .split() to turn it into a list). The next input is the integer that we are trying to determine is "everywhere".
Sample Input 1
1,2,1,3 1
Sample Output 1
True
There are three pairs in this list: (1,2), (2,1), and (1,3). Since 1 is in three of these pairs, it is "everywhere". Thus, we return true.
Sample Input 2
1,2,1,3 2
Sample Output 2
False
There are three pairs of adjacents in this list: (1,2), (2,1) and (1,3). Since 2 is NOT in all pairs, it is not "everywhere". Thus, we return false.
Sample Input 3
1,2,1,3,4 1
Sample Output 3
False
The input is not in all "pairs", e.g., not in (3, 4). Thus, we return false.

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 4 images

- Can you use Python programming language to to this question? Thanksarrow_forwardplease explain pythonarrow_forwardA user is going to enter numbers one at a time, entering 'q' when finished. Put the numbers in a list, sort it in numerical order, and print out the list. Then print out the middle element of the list. (If the list has an even number of elements, print the one just after the middle.) Remember that a list 1st of numbers can be sorted numerically by calling 1st.sort(), and can be printed with print(1st). You can assume that every entry is either a valid integer or is the letter 'q'. Examples: If the input is 4 3 6 7 3 q The output is [3, 3, 4, 6, 7] 4 If input is 4 3 6 7 3 2 q The output is [2, 3, 3, 4, 6, 7] 4arrow_forward
- Ask the user to input how many numbers to store in a list. Input the numbers as defined in Step 1. For e.g., if user wants 5 numbers, input 5 numbers. 3. Without using list functions or methods, find and print the following: a. The smallest number in the list b. The largest number in the list c. The total of the list d. The average of the numbers in the list.arrow_forwardWrite a program that uses 2 lists. Call the lists Items and Basket respectively. The first list will contain a list of at least 10 items (make up your own items) to select from. The second list will be used to add the selected items in the new list.(Basket) Your program should do the following in a Loop until the user exits the loop: Display the list (print out 1, 2, 3, 4, etc. before each item in the list (Hint: Use Index + 1) Prompt the user to select an item from the Items list. Add the selected item to the new list (Basket) (HINT: Use number entered - 1 for the Index) When the user selects 0, exit the loop and print out the new list of items (Basket)arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





