1 # DO NOT MODIFY THE FUNCTION HEADER 2 # This is autograded. If the autograder cannot run your co 3 def solution (word): 4 # your code goes here. # your submission should not contain any print statemen char_index = () 5 6 7 8 9 10 11 12 13 return -1 14 15 word=input(" ") 16 17 result = solution (word) 18 19 20 21 22 for index, char in enumerate (word): if char in char_index: return char_index [char] char_index [char] = index
1 # DO NOT MODIFY THE FUNCTION HEADER 2 # This is autograded. If the autograder cannot run your co 3 def solution (word): 4 # your code goes here. # your submission should not contain any print statemen char_index = () 5 6 7 8 9 10 11 12 13 return -1 14 15 word=input(" ") 16 17 result = solution (word) 18 19 20 21 22 for index, char in enumerate (word): if char in char_index: return char_index [char] char_index [char] = index
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
This code is exiting with an error and my instructor gave me this feedback… kinda confused.
![Character's Index
+
scaffold.py
1. # DO NOT MODIFY THE FUNCTION HEADER
2 # This is autograded. If the autograder cannot run your code,
3 def solution (word):
4
5
6
7
8 for index, char in enumerate (word):
9
if char in char_index:
10
return char_index [char] 3
char_index [char] = index
11
12
13 return -1
14
15 word = input(" ")
16
17 result = solution (word)
18
19
20
21
22
Challenge
# your code goes here.
# your submission should not contain any print statements
char_index = ()
/home/scaffold.py 11:5 Spaces: 4 (Auto)
Terminal
Sub
acBook Pro
All changes:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fce303429-f349-4313-b1b6-39c40e965b05%2F7ccfe2ee-3425-49a0-9b45-c7f45d559c65%2Fsmpqx5a_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Character's Index
+
scaffold.py
1. # DO NOT MODIFY THE FUNCTION HEADER
2 # This is autograded. If the autograder cannot run your code,
3 def solution (word):
4
5
6
7
8 for index, char in enumerate (word):
9
if char in char_index:
10
return char_index [char] 3
char_index [char] = index
11
12
13 return -1
14
15 word = input(" ")
16
17 result = solution (word)
18
19
20
21
22
Challenge
# your code goes here.
# your submission should not contain any print statements
char_index = ()
/home/scaffold.py 11:5 Spaces: 4 (Auto)
Terminal
Sub
acBook Pro
All changes:

Transcribed Image Text:Comment Edit Delete ...
Answer
A
Abenezer Dara STAFF
17 minutes ago
What is the data type of char_index? And how do we initialize that data type?
Comment...
Add comment
Kennedy Brown 14m
K
The data type of char_index an integer value. we initialize it by int() correct?
Reply Edit Delete
Abenezer Dara STAFF 12m
A
if char_index is an int, then you can't index into it like you are doing in line 11 or check if it contains
something in line 9.
Reply
&
7
***
8
Did you find a solution to your question?
Answer your question
4+
888
1
+
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education