Help with Dictionary funtion Programming Software Development by pacers10 …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "booty" : "treasure" , "grog… Re: Help with Dictionary funtion Programming Software Development by ultimatebuster …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "booty" : "treasure" , "grog… Re: Help with Dictionary funtion Programming Software Development by pacers10 …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "booty" : "treasure" , "grog… Re: Help with Dictionary funtion Programming Software Development by TrustyTony …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "booty" : "treasure" , "grog… Re: Help with Dictionary funtion Programming Software Development by TrustyTony …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "booty" : "treasure" , "grog… Re: Help with Dictionary funtion Programming Software Development by Schol-R-LEA …; , "restaurant" : "galley" , "hotel" : "fleabag inn" , "treasure" :"booty", "drink… Help on accumulator pattern troubles Programming Software Development by Memphis_212 …':'yer','is':'be','are':'be', 'restroom':'head','restaurant':'galley','hotel':'fleabag inn'} #initiate accumulator acc=[] #update accumulator words=string.split() for… Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 …':'yer','is':'be','are':'be', 'restroom':'head','restaurant':'galley','hotel':'fleabag inn'}[/CODE] The DEF shown is FAR from complete it… Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 …':'yer','is':'be','are':'be', 'restroom':'head','restaurant':'galley','hotel':'fleabag inn' } def toPirate(string): result = '' for word in dic.split… Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 …':'yer','is':'be','are':'be', 'restroom':'head','restaurant':'galley','hotel':'fleabag inn' } def toPirate(string, dic): result = '' for word in dic… Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 …':'yer','is':'be','are':'be', 'restroom':'head','restaurant':'galley','hotel':'fleabag inn'} #initiate accumulator acc=[] #update accumulator words=string.split() for… Basic Java Translator using HashMap Programming Software Development by nipur23 …", "galley"); hashmap.put("hotel", "fleabag inn"); hashmap.put("pub", "Skull &… Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony So you want example of accumulate pattern different from yours? You should accumulate string result and put space between words, because you want to return string. Normaly in Python we would use ' '.join(generate_the_words) but that is other, generator pattern. Looks like you could use little repetion of how functions work. Have you read through … Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony Here is accumulate pattern with summing numbers (primes), see also use of functions, returning string instead of number value and alternative better ready Python way with filter: [CODE]""" Accumulate sum of primenumbers less than 100 by function and return verbal string answer """ def isprime(n): ""&… Re: Help on accumulator pattern troubles Programming Software Development by richieking very neat stuff! ;) Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 Ok I realize the Def is unfinished .. but I have no clue how to end this to return the way I want it to .. and although I ''KNOW'' there are better ways.. my teacher wants me to do this with accumulator pattern.... So it confuses me very much because he refers me to the book instead of helping me. The book says 'this does that' and 'that does … Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony Ok, here another example (join method I do not use) [CODE]numberdict={ 'one':'1', 'three':'3', 'seven':'7' } def numbers(numbertext): result = '' for number in numbertext.split(): if result: result += ' ' # space not after empty string if number in numberdict: result += numberdict[number] … Re: Help on accumulator pattern troubles Programming Software Development by richieking look i dont ge you. do you have to search the dictionary for the word occurance and print them out + a custom words ??? help is on the way Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 [CODE]numberdict={ 'one':'1', 'three':'3', 'seven':'7' } def numbers(numbertext): result = '' for number in numbertext.split(): if result: result += ' ' # space not after empty string if number in numberdict: result += numberdict[number] else: result += number return result … Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony Looks good except the extra [] at line 12. Re: Help on accumulator pattern troubles Programming Software Development by richieking The dic Dictionary is not declared anywhere in your function toPirate. Neither is it refferenced to. how do you code. line #8 [CODE] for words in dic.split(string) #????? [/CODE] define your function to either contain the dic. Such as [code] def toPirate(string, **dic): [/code] here you can pass the dic as the last arg. Also on line 12 result+=[… Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 Could an admin delete this post instructor helped me with it and there is no real answer that i saw here anyways thank. Re: Help on accumulator pattern troubles Programming Software Development by richieking We dont solve problems here my good friend. we share ideas and give direction. You are welcome anytime ;) Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 No sorry I do not mean to say you didn't help me or give me ideas .. I simply mean to say I am too new to understand them at the moment unless they are put in ''noobie'' terms :D so don't feel you didn't help cause with the last 2-3 posts you helped me alot .. I am just new to the forum and also didn't know there was a second page on this until … Re: Help on accumulator pattern troubles Programming Software Development by Memphis_212 Sorry to triple post .. tried to edit but didn't let me :( what is [CODE]+=[/CODE] I cannot find it in my book all i have is <, <=, >, >=, ==, and also != meanings in my python book ... Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony [CODE] for word in dic.split(string):[/CODE] means split dic where occurs string string, which is not what you mean, you want to split string from default place (no parameters), which is whitespace. So you want: [CODE] for word in string.split():[/CODE] Did you prove += interactively. Use the interpreter (Python shell) to experiment: [CODE]… Re: Help on accumulator pattern troubles Programming Software Development by richieking Hi, to be precise 1. Your method/function needs 2 arg but you gave only 1. 2. The logic of your function is not complete and will never get you what you want. The logic flow is not ok. If you want a fuction to check up words in your dic, its a piece of cake. But untils know... we are going in circles i think. Put the cards on the table.... … Re: Help on accumulator pattern troubles Programming Software Development by TrustyTony Compare the code's condition to condition in post [url]http://www.daniweb.com/forums/post1372272.html#post1372272[/url] Re: Basic Java Translator using HashMap Programming Software Development by JamesCherrill "But token in my opinion works better" Obviously not. If the input can be multiple words separated by blanks then either you have to loop reading all the tokens on the line then concatenate them again, or just read the whole line. Re: Basic Java Translator using HashMap Programming Software Development by Julian_3 Hello, I copyed the code and pasted in the coding program but i saved it but how can i then test it do i need to ad another code to see it in a program thing? and what code?