# Homework 4.7

 0 Why Cant we just have a break statement? My code : def add_to_index(index, keyword, url): for entry in index: if entry[0] == keyword: entry[1].append(url) return break # not found, add new keyword to index index.append([keyword, [url]])  asked 20 Mar '12, 23:56 Kanika Kharb... 461●2●7●17 accept rate: 37% JohanG-Sweden 9.4k●12●42●100 I formatted the code. (21 Mar '12, 05:08) JohanG-Sweden

 0 Why would you be breaking out of the loop before going through all of the different entry[0] values? answered 21 Mar '12, 00:02 Stuart M. Sc... 2.9k●2●6●19
 0 You may want to indent the code to see where you have return & break. Just highlight the code after you paste in the text entry window and click the format button on the top that has 101010. This information is thanks to a gentleman who pointed out this to me couple weeks back. answered 21 Mar '12, 00:04 Arvind Deogi... 657●1●7●27
 0 You used a return & then a break? I'm not sure about the indenting, but I think the break statement stops the function from getting to the last statement, which means nothing is appended to your index if the keyword isn't already present in the index. Also, you needed to add a counter to every url. You don't do that here. answered 21 Mar '12, 00:04 elssar 19.2k●25●63●155
Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

### Tags:

×15,224
×161
×41

Asked: 20 Mar '12, 23:56

Seen: 151 times

Last updated: 21 Mar '12, 05:08