The idea is to replicate your python logic with psychopy’s own components in the builder.
So you replace the the input()-function with psychopy’s textbox component. You replace the while-loop with psychopy’s loop. You replace the print()-function with psychopy’s text-component. Etc.
You may still use custom code by inserting it with psychopy’s code components (like the random number generation). But the flow and I/O should use psychopy’s components.
I attached a minimal working exampl of how this could be constructed within psychopy.
untitled.psyexp (22.3 KB)