Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem With Tutorial
#11
I don't think that's a real [ as the 3 dots are all aligned with each other
After pressing enter at the end of line
print('No, I really really like ' + dog +'s!\n')
if you press space until the text wraps then type
... print("\nThat's just how I feel about dogs.")
it will show the same as the picture less the phantom [

nope scrub that because you get the 3 ... in the error message which is not in the photo, but I still thin the bracket is a phantom


This could be it
print('No, I really really like ' + dog +'s!\n')
press enter
add 4 spaces and press enter
add
print("\nThat's just how I feel about dogs.")
>>> for dog in dogs:
...     print('I like ' + dog + 's.')
...     print('No, I really really like ' + dog +'s!\n')
...
... print("\nThat's just how I feel about dogs.")
  File "<stdin>", line 5
    print("\nThat's just how I feel about dogs.")
        ^
SyntaxError: invalid syntax
>>>  
Reply
#12
(Jun-15-2020, 09:18 PM)Yoriz Wrote: it will show the same as the picture less the phantom [
nope scrub that because you get the 3 ... in the error message which is not in the photo, but I still thin the bracket is a phantom
No, you are right. And it's the mouse cursor, moved there after the error get displayed
(Jun-15-2020, 09:18 PM)Yoriz Wrote: press enter
add 4 spaces and press enter
add
Now it makes perfect sense. :-)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#13
With a better shell like ptpython or IPython can paste in whole code then only one Enter and it work.
But in general this code should be run as a script.
Example:
G:\1_youtube
λ ptpython
>>> dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
...
... for dog in dogs:
...     print('I like ' + dog + 's.')
...     print('No, I really really like ' + dog +'s!\n')
...
... print("\nThat's just how I feel about dogs.")
I like border collies.
No, I really really like border collies!

I like australian cattle dogs.
No, I really really like australian cattle dogs!

I like labrador retrievers.
No, I really really like labrador retrievers!


That's just how I feel about dogs.

>>>
G:\1_youtube
λ ipython
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
   ...:
   ...: for dog in dogs:
   ...:     print('I like ' + dog + 's.')
   ...:     print('No, I really really like ' + dog +'s!\n')
   ...:
   ...: print("\nThat's just how I feel about dogs.")
I like border collies.
No, I really really like border collies!

I like australian cattle dogs.
No, I really really like australian cattle dogs!

I like labrador retrievers.
No, I really really like labrador retrievers!


That's just how I feel about dogs.

In [2]:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020