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
icon
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:
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:
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
+
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
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education