0

I'm very new to python/ programming in general

I'm making a script in which the user is given a random square number & has to report the square root of that number

The script itself is working fine, assuming I save the file within sublime, then run it separately through IDLE

When I press Ctrl + B, the script runs within sublime, but i'm unable to input anything (I type the number and press enter). In IDLE, typing the answer and pressing enter would show the next line

my input function itself is

x = int(input("What is the square root of "+str(b)+"? "))
martineau
  • 119,623
  • 25
  • 170
  • 301
BillieM
  • 195
  • 2
  • 11
  • Does this answer your question? [Sublime Text 2 console input](https://stackoverflow.com/questions/10604409/sublime-text-2-console-input) – OdatNurd Dec 18 '19 at 01:56
  • 1
    This is a very commonly asked question and it most certainly a duplicate (there are tons of duplicates of this). Answers vary, but the crux is that Sublime doesn't support interactive programs out of the box; you need to use an external package like [Terminus](https://packagecontrol.io/packages/Terminus) (or maybe [SublimeREPL](https://packagecontrol.io/packages/SublimeREPL), but it's no longer maintained). – OdatNurd Dec 18 '19 at 01:57

2 Answers2

0

What is your question? Is it input not showing through launch with command line or through IDLE?

Something like this?

import random
import math

given = random.randint(0,10) ** 2

print(given)

answer = input(f'Whats is the square root of {given}? ')

print('The square root is ', answer)

if math.sqrt(given) == int(answer):
    print('This is correct')
else:
    print('Wrong answer')

It is working fine for me both through command line, and in IDLE.

awasi
  • 369
  • 1
  • 9
-1

Unfortunately, Sublime Text does not support inputting data into a program. You will have to continue running your program separately. Or switch to a better IDE such as Visual Studio Code, which can be found here: https://code.visualstudio.com

damaredayo
  • 1,048
  • 6
  • 19