Hi,
It appears that \hskip is parsing the “P” as part of the skip amount. You get
similar trouble with “M”, “p”, and “m”.
Putting \relax at the end of the skip amount works for me. Perhaps there is a
better solution?
…
\hskip 1ex def proba(k):
\hskip 1ex\relax P = 0
\hskip 1ex for i in range(0,k+1):
…
Michael
On Jan 24, 2026, at 1:46 PM, Fabrice Couvreur <[email protected]>
wrote:
Hi,
The following code (thanks Wolfgang!) allows me to write a Python program while
preserving indentation. However, this code stops working if I use \hskip
starting from line P=0.
Thank you for your help.
Fabrice
\defineframedtext
[algorithmframe]
[width=fit,
foregroundstyle={\tt\switchtobodyfont[11pt]},
framecolor=,
rulethickness=,
location=middle,
after=,
before=,
]
\startlinecorrection[blank]
\startmidaligned
\algorithmframe{
from math import comb
\hskip 1ex def binomiale(i,n,p):
\hskip 4ex return comb(n,i) * p**i * (1-p)**(n-i)
\hskip 1ex def proba(k):
P = 0
for i in range(0,k+1):
P=P+binomiale(i,20,0.5)
return P
}
\stopmidaligned
\stoplinecorrection
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________