Library
/
Datadisplay
/
Codeblock
The CodeBlock component can be used to display code easily within a website. Put in a multiline string with the correct spacing and specify and language to show the desired code.
1 2 3 4 5
def fib(n): if n <= 1: return n else: return(fib(n-1) + fib(n-2))
rx.code_block(
"""def fib(n):
if n <= 1:
return n
else:
return(fib(n-1) + fib(n-2))""",
language="python",
show_line_numbers=True,
)
Did you find this useful?