The site you get code from use plain HTML without even a <code> tag to display the code this is bad.
Usually if make a site where people post a lot of code,then have some kind of
If look at source eg:
So can get strange result if try to copy code,look like you have written the code over as there are typo's to.
The code work,here a cleaned up versions and i made a few changes.
Usually if make a site where people post a lot of code,then have some kind of
code box
.If look at source eg:
<span style="background-color:#ffffcc"> cache[args] = result</span>A overflow of
 
💥So can get strange result if try to copy code,look like you have written the code over as there are typo's to.
The code work,here a cleaned up versions and i made a few changes.
import time def memoize(func): cache = {} def wrapper(*args): if args not in cache: cache[args] = func(*args) return cache[args] return wrapper def timed(func): def wrapper(*args): start = time.time() result = func(*args) end = time.time() elapsed_time = end - start print(f"Elapsed time: {elapsed_time:.6f} seconds") return result return wrapper @memoize @timed def sum_of_odd_numbers(n): return sum(x for x in range(n) if x % 2 == 1) print(sum_of_odd_numbers(10000000)) print(sum_of_odd_numbers(10000000))
Output:Elapsed time: 0.759998 seconds
25000000000000
25000000000000