Terminal control/Positional read: Difference between revisions

Add Python solution
(Added Kotlin)
(Add Python solution)
Line 166:
</pre>
 
=={{header|Python}}==
<lang python>import curses
from random import randint
 
 
# Print random text in a 10x10 grid
stdscr = curses.initscr()
for rows in range(10):
line = ''.join([chr(randint(41, 90)) for i in range(10)])
stdscr.addstr(line + '\n')
 
# Read
icol = 3 - 1
irow = 6 - 1
ch = stdscr.instr(irow, icol, 1).decode(encoding="utf-8")
 
# Show result
stdscr.move(irow, icol + 10)
stdscr.addstr('Character at column 3, row 6 = ' + ch + '\n')
stdscr.getch()
 
curses.endwin()
</lang>
 
{{out}}
<pre>T@4;4G,XIJ
>C+PE0)RM;
JEV6B/8E?H
FSC>41UIGR
V>41JMXMOW
IY0*KH6M;B Character at column 3, row 6 = 0
-6<UL*>DU7
MZ))<5D:B8
.@UB/P6UQ)
<9HYH)<ZJF
</pre>
=={{header|Racket}}==
Works in a CMD box on Windows:
Anonymous user