User input/Graphical: Difference between revisions

→‎{{header|Processing Python mode}}: int conversion fail-safe
(add task to ARM64 assembly Raspberry Pi)
(→‎{{header|Processing Python mode}}: int conversion fail-safe)
Line 2,563:
<lang Python>from javax.swing import JOptionPane
 
def to_int(n, default=0):
# Causes ValueError if non int literal is entered
try:
number = int(JOptionPane.showInputDialog ("Enter an Integer"))
return int(n)
except ValueError:
return default
 
number = intto_int(JOptionPane.showInputDialog ("Enter an Integer"))
 
string = JOptionPane.showInputDialog ("Enter a String")</lang>
 
Anonymous user