Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called game_of eightsl that accepts a list of numbers as an argument and then returns True if two consecutive eights are found

image text in transcribed

Write a function called game_of eightsl that accepts a list of numbers as an argument and then returns True if two consecutive eights are found in the list. For example: [23,8,8,9 True. The mainl) function will accept a list of numbers separated by commas from the user and send it to the game ot eightsl) function. Within the game.of eights() function, you will provide logic such that 1. the function returns True if consecutive eights (8) are found in the list; returns False otherwise. 2 the function can handle the edge case where the last element of the list is an 8 without crashing. 5. the function prints out an error message saying Error Please enter only integers. if the list is found to contain any non-numeric characters. Note that it only prints the error message in such cases, not True or False Examples: Enter elements of list separated by commas: 2,3,8,8,5 True Enter elements of list separated by commas: 3,4,5,8 False Enter elements of list separated by commas: 2,3,5,8,8,u Error. Please enter only integers. Hint: You will need to use try-except to catch exceptions. Code codepy &New Full Screen 3 def main): alist input("Enter elements of list separated by commas. ").split(',') result -game of eights (a list) 7 main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

Students also viewed these Databases questions