# exam 7.1 starred - I didnt know they were gonna test with other dictionaries imputs

 0 i got everything correct excepts for 7.1, because i didn't check for empty nodes cases, i thought the graph was not gonna change, like when they give us a cache, they are not suppose to change that. do you think a person with this stupid errors can be a professional programmer? or a prof in any field? asked 13 Apr '12, 16:18 maiza 2.1k●21●55●65 accept rate: 40% What input does it say you failed on? (13 Apr '12, 16:32) PeterUdacity ♦♦

 3 First off, of course they were going to try other inputs. Second, if you learn from your mistakes and continue to you'll be fine. It's not like if you had got perfect scores on all the quizzes and homework assignments you would have been at the level of a professional programmer after this course anyway. This is just a beginning. answered 13 Apr '12, 16:21 mhurron 2.6k●1●11●35 Excellent answer on both counts :-) (13 Apr '12, 16:30) JohanG-Sweden Like he said, you're just getting going. And yes, professional programmers make far "dumber" errors all the time :) Learn the lesson! Consider fringe cases! (13 Apr '12, 16:40) Adam Urato
 1 Aushin was correct, your code returns ['g','g'] instead of ['g']: output = [node] + graph[node] resolves to: output = ['g'] + ['g'] edit: added missing quotation marks edit2: There's also a second situation in which case your code will not return the correct result for an input like: reachable({'c':['d'],'b':['c'],'a':['b']}, 'a') it will return ['a','b','c'] instead of ['a','b','c','d'] because the first element will be checked when only ['a','b'] are in your output list, and it will not add 'd' as a result. this is a bit tricky to test for, because since dictionaries are hash tables, the order of the entries might not actually be the one that you typed in, but it works to show the point with the input above. answered 13 Apr '12, 19:37 Krzysztof E ... 56●5
 0 This doesn't sound right, @maiza , There was a question in the forum that Peter answered that they would not be testing for the case of an empty node. Check it out: http://www.udacity-forums.com/cs101/questions/54709/exam-starred-question-1-what-is-the-expected-behaviour-if-the-node-is-not-in-the-graph answered 13 Apr '12, 16:31 Susan Straub 2.2k●4●17●47
 0 this is the input that gives me an error, according to the tester machine  graph = {'a': ['b', 'c'], 'c': ['b', 'd'], 'b': ['a', 'c'], 'e': ['a'], 'd': ['a'], 'g': ['g'], 'i': ['k'], 'k': []}, 'g'  answered 13 Apr '12, 16:42 maiza 2.1k●21●55●65 1 reachable(graph, 'g') returns ['g', 'g'] more than likely. (13 Apr '12, 16:46) Adam Urato and k? also they dont tell you witch node are they testing. (13 Apr '12, 16:49) maiza somebody who got it right, tell me what this returns for all of entries. (13 Apr '12, 17:05) maiza
 0 that's my case on 7.2 starred. got it right in 5 out of 6 cases ): answered 13 Apr '12, 16:43 Radiohead 432●5●12●24
 0 def reachable(graph, node): if node == '' or not node in graph: return [] else: output = [node] + graph[node] for n in graph: if n in output: # add node for i in graph[n]: if not i in output: output += [i] return output  this is my code, maybe you can tell me what is wrong. answered 13 Apr '12, 18:55 maiza 2.1k●21●55●65
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

×15,261
×683
×172
×18
×11
×5