a=raw_input()
prefix_dict = {}
for j in xrange(1,len(a)+1):
prefix = a[:j]
prefix_dict[prefix] = len(prefix)
print prefix_dict
Is there any possibility of memory error in the above code?
Is there any possibility of memory error in the above code? |
||||
| show 2 more comments |
|
It's hard to tell what is making the error occur without giving us the input, but it's certainly possible the input is too large for the system to store.
I will note that instead of having Take a look at the sample output (I modified the print statement and used an example string):
|
|||
|
|
|
The slice operator in |
|||
|
|
prefix = a[:j]. – sachin irukula Jul 23 '12 at 16:02