Python output Terminal

Hello all, I am very new to coding and new to this community. I am using solo learn and Python Crash Course book to teach myself. I want a deer understanding of what I am learning. I don’t want to mindlessly enter code. I want to understand why things are happening. On solo learn they give an example on my things and I have noticed when I use VS code to enter the EXACT same thing often it does not work. Why? I find that my questions are very specific and very difficult to find the right information online. For example

email = input()
print(email)


My output on VS code is:

"/usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py
shawnbrandon@shawns-mbp python_work % /usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py
/usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py
/usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py
shawnbrandon@shawns-mbp python_work %
shawnbrandon@shawns-mbp python_work %

`

If I enter print('hello") that has an output. Why does this work and not the other. Can anyone help. I don’t want to skip over this. I truly want to underhand so I can grow into this new thing that I have been enjoying so far learning. Thank you all and if I am not doing this post right please let me know. First post on here.

Hi Shawn.

When you run this code:

email = input()
print(email)

What do you know about that code and what it is doing?

I ask, so that I can assess your understanding, because you’re saying (or what I think that you’re saying) that the code is not working.

I understand why you’re asking and thank you for taking the time.

I made the variable “email” ask for an input from the user.
then print(email). should print the variable in the output terminal so that the user can put their email in the output (terminal). Correct?

thanks again

You’re welcome.

I can see that you’ve kind of got it, save to say, that the ‘object’ that you’ve named email will hold a string of characters that is returned from the input() function, which in turn is what is entered by the user.

So, what is it about that code that is not working? Or is that not what you’re saying?

When I run it there is no output. I don’t think solo learn is teaching me the right things. There is a gap and I don’t know what I’m missing.

email = input("Please enter Email ") message = "Correct Email Entered " + email print(message)

I can run this code and I can interact with it on the output terminal.

If I just run
email = input() print(email)
All I get is this in the terminal:
/Desktop/python_work/solo_learn2.py /usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py /usr/local/bin/python3 /Users/shawnbrandon/Desktop/python_work/solo_learn2.py shawnbrandon@shawns-mbp python_work %
it doesn’t ask for anything in VS code

Ah, okay. Let’s leave VS code out of this, for now.

Use a plain text editor and c&p this code into it:

#!/usr/bin/python3
email = input("> ")
print(email)

… and save it into your /Desktop/python_work/ directory as test.py
In your terminal, navigate to your /Desktop/python_work/ directory and enter ls and you should see that you have that new file.

Now, you’ll need to make that file be ‘executable’: chmod 700 test.py

Now you can run the script with ./test.py

Does that work?

I am following your instructions. One sec and Ill try

You can also run it with python3 test.py, having first done a cd into the working directory, without having to run the chmod command.

how do I upload the code to you in a “neat” way the same as you do?

You use ‘Markdown’ formatting, like this:

```python
#!/usr/bin/python3
email = input("> ")
print(email)
```

… which is what the code formatting will look like, before you post it. The Forum software will then render the code block in the way that you see it in my posts.

Blockquote

t Last login: Sun Aug 13 17:02:28 on console

shawnbrandon@shawns-mbp ~ % ls

Desktop Downloads Movies Pictures

Documents Library Music Public

shawnbrandon@shawns-mbp ~ % ls desktop

python_work

shawnbrandon@shawns-mbp ~ % ls python_work

ls: python_work: No such file or directory

shawnbrandon@shawns-mbp ~ % ls

Desktop Downloads Movies Pictures

Documents Library Music Public

shawnbrandon@shawns-mbp ~ % cd Desktop

shawnbrandon@shawns-mbp Desktop % ls

python_work

shawnbrandon@shawns-mbp Desktop % cd python_work

shawnbrandon@shawns-mbp python_work % chmod 700 test.py

shawnbrandon@shawns-mbp python_work % ./test.py

./test.py: line 1: {rtf1ansiansicpg1252cocoartf2709: command not found

./test.py: line 2: syntax error near unexpected token `}'

./test.py: line 2: `\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}'

shawnbrandon@shawns-mbp python_work % python3 test.py

File "/Users/shawnbrandon/Desktop/python_work/test.py", line 1

{\rtf1\ansi\ansicpg1252\cocoartf2709

^

SyntaxError: unexpected character after line continuation character

shawnbrandon@shawns-mbp python_work %

I tried both and no luck on either way.

I don’t think that you’re using a plain text editor, are you?

Maybe your have xed, or Gedit? Or from your terminal, you can also use nano, but it’s less than ideal.

I am on macOS and using textedit. I can try to find another software

Ah, okay. It’s just that the error you’re seeing would suggest that the test.py file has been saved as a ‘rtf’, rather than ‘plain text’.

I changed the file type to .py file do I need to change it to a .txt file?

No: it should be a .py file, so that you know that its a Python script, but whatever text editor you’re using, should be set to save the file as ‘plain text’.

downloading another software to try.

both worked!
I have a little better understanding because of you. thank you
is VS code good to use?
How can I have better understanding of all this? I really enjoyed just this little bit. thank you thank you.

You’re very welcome. I can’t speak about VS code, as I don’t use it, but from what I understand, it’s not a bad choice. Maybe there’s some settings that need to be changed so that it [VS code] can be used on your system. Perhaps someone on this Forum that does use VS code can help you with that.

Happy coding and feel free to ask for help should you need it, but please remember to post any Python code in a formatted code block, in the way that I’ve illustrated.