0

I have recently installed sublime text 4 on my system. While running my python code on ST 4, I'm encountering a strange issue which I'm unable to resolve. The following code is suppose to take input from use, Here First name and the second name. after running the code it ask to enter first name and the the second name on the next line but the line that line isn't printing on the editor?! I tried running my code on other editors (pycharm) and online editors and its working just fine giving me the output I was expecting. I think my sublime text is broken or If is there any settings or something I shall suppose to change to fix this issue?

Here's the code:

               first_name = input("Enter your first name? ")
               last_name = input ("Enter your last name? ")
               full_name = f'{first_name} {last_name}'
               print (f'Hello,{full_name.title()}!')

The Problem with running the code on sublime is it's not asking for second user input?

enter image description here

Note: I'm at beginner level learner and non native English speaker so I apologies if I'm unable to explain the problem properly.

viveooo
  • 37
  • 7
  • Please see the marked duplicate for additional information. The accepted answer below is not complete. – MattDMo Apr 08 '22 at 15:46

1 Answers1

2

Sublime Text does not directly support receiving user input in programs. Sublime Text is not broken!

You can, however, install SublimeREPL via Package Control on Sublime, which allows you to run an interpreter directly inside Sublime, which would let you provide user input.

I also use Sublime for most of my code. However, when it comes to interactive code, I recommend either using your terminal / command prompt (my first choice) or iPython (which can also be run on your terminal).

I hope this helps. Please let me know if there are any questions!

OTheDev
  • 2,916
  • 2
  • 4
  • 20
  • How do I run it inside the ST 4 just like we do in pycharm? also can yo tell me how to (can) I use terminal in ST4 to run codes? please guide me with this. Thankyou for the reply. Here is the [link](https://imgur.com/0FnzymV) – viveooo Apr 08 '22 at 11:17
  • 1
    On Sublime, click on `preferences`, followed by `Package Control`. Once you click on `Package Control`, type 'install' and click on `Package Control: Install Package`, then search for `SublimeREPL` then click on `SublimeREPL`. Once it is installed, go to `Tools`, then `SublimeREPL` -> `Python` -> `Python`. – OTheDev Apr 08 '22 at 12:12
  • 1
    At this stage, it might work already for you -- it will open a new tab where you have an interactive interpreter. If you get a file not found error you will likely need to find where `/SublimeREPL/config/Python` is on your file system, open `Main.sublime-menu` and if you see a row under `"command": "repl_open"` that says something like `"cmd": ["python", "-i", "-u"]`, change `python` to, say, `python3`, if that is how you normally access Python via the terminal. For me I changed it to `python3.10`. Once this is done, go to `Tools` -> `SublimeREPL` -> `Python` -> `Python` and all should be good – OTheDev Apr 08 '22 at 12:12
  • 1
    Note that this procedure may be system-dependent. If this is a little too much you can search google and/or youtube on how to set up `SublimeREPL`. There are a lot of resources on this! Hope this helps @viveooo. – OTheDev Apr 08 '22 at 12:16
  • 1
    Thankypu for this!! I took your word for it and went to youtube to look for interactive code in sublime text and find a valuable information regarding new system build. I'm now using terminus to run my code on ST4, took me hours to go through it but finally now able to run my program!! Love ye bro!! Edit: I found this useful channel tons of resources on ST4. Here's link to it [link]https://www.youtube.com/watch?v=etIJMVIvVgg – viveooo Apr 08 '22 at 16:17
  • Happy to help! Setting up our development environments is an investment! – OTheDev Apr 08 '22 at 16:20