Search code examples
python-3.xsublimetext3

Why Sublime text3 can't run this code in build system while terminal runs it?


I am new to programming and I ran this code in terminal(mac), it just works fine. However when I tried to run it in sublimetext 3, it doesn't run. Sublime is set to run on python version 3.

lst=[]

while True:
    a=input('enter a number: ')
    if a=='done':
        break
    val=float(a)
    lst.append(val)

print('average',sum(lst)/len(lst))

Solution

  • The code runs without error. The only problem is it doesn't print anything, partially because you enter an infinite loop if you enter something other that "done".

    Also, sublime build editor typically isn't used for input statements or anything related to the program waiting. Build editor is used for raw output, or physical immediate output, although this isn't an official statement.

    Hope this answers your question!