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
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.
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?
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?
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
… 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
… 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.
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 %
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’.
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.