Python for Dummies exaple

2015-10-14 Thread NewsLeecher User
Hello,
I have the book Python for Dummies and i downloaden from the Dummiesite some 
python examples.
But with this script i get an error:
But i have not so many experience to see what the error is.
Good someone help me with this ?

#Chapter 3
#Basic Elements and Syntax
#=
#SHORT EXAMPLES
#=

#while loop example
countdown = 10
while countdown:
print countdown,
countdown -= 1
print "blastoff!"

#
#

#try statement with input
user_input = raw_input("Enter an integer: ")
try:
number = int(user_input)
print "You entered", number
except ValueError:
print "Integers, please!"

#class example
class SayMyName:
def __init__(self, myname):
self.myname = myname
def say(self):
print "Hello, my name is", self.myname

name1 = SayMyName("Aahz")
name1.say()

#
#




-- 
- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python for Dummies exaple

2015-10-14 Thread NewsLeecher User
In reply to "edmondo.giovanno...@gmail.com" who wrote the following:

> Il giorno mercoled=EC 14 ottobre 2015 12:04:30 UTC+2, Chris Angelico ha scr=
> itto:
> > On Wed, Oct 14, 2015 at 8:55 PM, NewsLeecher User wrote:
> > > But with this script i get an error:
> > > But i have not so many experience to see what the error is.
> > > Good someone help me with this ?
> > =20
> > You need to tell us what the error is :)
> > =20
> > But, looking in my crystal ball, I find a hint that you're using
> > Python 3 and a book that's teaching an older version of Python.
> > Solution: Get a better book.
> > =20
> > ChrisA
> 
> And using the same cristal ball, assuming you are using python 3.x, put bra=
> ckets around the arguments of print like:
> 
> print(countdown)
> ...
> print("Hello, my name is", self.myname)
> 
> etc.
> forget for the moment about the ending comma.

Thanks for the reply.
Oh i did not look good enough that the examples are written in python 2.7
But there are also good things explaning in the book so i will keep it.

Thanks



-- 
- --- -- -
Posted with NewsLeecher v7.0 Beta 2
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

-- 
https://mail.python.org/mailman/listinfo/python-list