Trying to learn Python; is this book incorrect?

  • Context: Python 
  • Thread starter Thread starter jkoster09
  • Start date Start date
  • Tags Tags
    Book Python
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
10 replies · 2K views
jkoster09
Messages
15
Reaction score
0
I had a brief stint with Python a year or two ago, and after I learned of the Raspberry Pi I knew I should try to learn again. I purchased this book, knowing full well that the online resources would be sufficient, and some of the code doesn't seem to work.

hello_str = "Hello World"

hello_bool = True

hello_truple = (21, 32)

hello_list = ("Hello,","this","is","a","list")

hello_list = list()
hello_list.append("Hello,")
hello_list.apppend("this")
hello_list.append("is")
hello_list.append("a")
hello_list.append("list")

hello_dict = {"first_name":"*My First Name*",
"last_name":"*My Last Name",
"eye_color":"*My Eye Color*"}
print(hello_list[4])
hello_list[4]+="!"

This is the code copied verbatim from the book. It gets an error at the part with multiple append commands, but even when I comment that out it also hangs on the final line. What am I missing here? If it's any help, the book is simply titled "The Python Book: The ultimate guide to coding with Python". It says it's written for 2.x, but I tried 3 just to be sure. No luck.
 
on Phys.org
jkoster09 said:
hello_list.apppend("this")
Well this looks like the source of the error. Works fine for me with this fixed.
An important part of coding is learning how to debug - so its good to learn how to interpret the error messages that the interpreter throws at you.
 
Thanks, that helped me fix it. I didn't even notice that it wasn't the first append that it hung up on, or else I might have fixed it myself. Thank you.
 
Mark44 said:
It looks like they appended an extra 'p' on "append". Was this how it was in the book?
No, that was my fault. I'm going to stick to sleep depravity as my excuse for that obvious slip up.
 
jkoster09 said:
If it's any help, the book is simply titled "The Python Book: The ultimate guide to coding with Python". It says it's written for 2.x, but I tried 3 just to be sure. No luck.
From what I can tell, that is not a good book. How did you find it? Just because there are lots of free (but illegal) downloads for that book does not mean it is good. From what I've seen, if the first google page on searching the title of a book comprises almost entirely links to various torrent sites, run away. It's not a good book.

Python is an open source language, and as such, you can find lots and lots of free (and legal) tutorials on how to program in python. As a starter, I suggest you go to the source, python.org. For python2, look to https://docs.python.org/2/tutorial, and for python3, https://docs.python.org/3/tutorial. They're both free, they're both very good, and they're both legal.
 
I bought it at a local bookstore, so it is completely legal. And I recognize that there are many free and probably better online resources, but I have a need for the physical thing that I can't explain. I'll use it to some extent, but I'll almost certainly resort to these online sources soon, just not yet.
 
https://www.imagineshop.co.uk/the-python-book.html
 
Last edited by a moderator:
jkoster09 said:
And I recognize that there are many free and probably better online resources, but I have a need for the physical thing that I can't explain.

That is something I totally understand. To me, there's just something magical about words on paper that words on a computer screen cannot yet replicate. If you wish, you can highlight those words on paper with a yellow marker in the blink of an eye. You can do that with a computerized book,but not in a blink of an eye. You can flip from page 1 to page 101 in the blink of an eye with a book on paper; good luck with that with a computerized book.

Done wrongly, that computer-based facsimile is just that, a facsimile. Done correctly, a computer-based version of a book or journal paper is anything but a facsimile of a paper copy. Good luck searching a paper copy for a keyword. It's cinch with a properly done computerized version. That's but one of the magical features of computerized papers.