I am out of trial and error again Lists

Seymore4Head Seymore4Head at Hotmail.invalid
Sat Oct 25 20:42:10 CEST 2014


On Sat, 25 Oct 2014 14:23:44 -0400, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:

>On Fri, 24 Oct 2014 10:38:31 -0400, Seymore4Head
><Seymore4Head at Hotmail.invalid> declaimed the following:
>
>>
>>I do get the difference.  I don't actually use Python 2.  I use
>>CodeSkulptor.  I do have Python 3 installed.  Actually I have Python 2
>>installed but IDLE defaults to Python 3.  So it is a pain to actually
>>load Python 2.
>>
>
>	So don't use Idle... Open up a Windows command shell and invoke Python
>without giving a script file to execute.
>
>C:\Users\Wulfraed\Documents>python
>ActivePython 2.7.5.6 (ActiveState Software Inc.) based on
>Python 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit (AMD64)]
>on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> exit()
>
>C:\Users\Wulfraed\Documents>python3
>ActivePython 3.3.2.0 (ActiveState Software Inc.) based on
>Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)]
>on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> exit()
>
>C:\Users\Wulfraed\Documents>
>
>	Note that my default Python is still 2.7, but I also have Python 3.3
>installed, and can access it using "python3" (I can also ensure Python 2.7
>by using "python2")
>
>
>>
>>I tried list(range(10)  I thought that would work in Python 3.  It
>>didn't.  I spent quite a bit of time last night trying to come up with
>
>	Really? what did it do? SHOW US!
>
>C:\Users\Wulfraed\Documents>python3
>ActivePython 3.3.2.0 (ActiveState Software Inc.) based on
>Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)]
>on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> list(range(10))
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> print(list(range(10)))
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> repr(list(range(10)))
>'[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
>>>>
>
>	Recall that "print" is a function in Python 3, so the extra layer of ()
>are required.
>
>C:\Users\Wulfraed\Documents>python
>ActivePython 2.7.5.6 (ActiveState Software Inc.) based on
>Python 2.7.5 (default, Sep 16 2013, 23:11:01) [MSC v.1500 64 bit (AMD64)]
>on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> list(range(10))
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> print list(range(10))
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> print(list(range(10)))
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> repr(list(range(10)))
>'[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
>>>>
>
>	"Print" doesn't need the (), but they also don't hurt it in Python 2.
>(still in Py2)
>
>>>> range(10)
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> xrange(10)
>xrange(10)
>>>> print range(10)
>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>> print xrange(10)
>xrange(10)
>>>> exit
>Use exit() or Ctrl-Z plus Return to exit
>>>> exit()
>
>	Now Py3
>
>C:\Users\Wulfraed\Documents>python3
>ActivePython 3.3.2.0 (ActiveState Software Inc.) based on
>Python 3.3.2 (default, Sep 16 2013, 23:11:39) [MSC v.1600 64 bit (AMD64)]
>on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> range(10)
>range(0, 10)
>>>> xrange(10)
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>NameError: name 'xrange' is not defined
>>>> print(range(10))
>range(0, 10)
>>>>

I am not working on that any more.  I have my assignment for this week
so I am done with busy work.

Thanks for all your help



More information about the Python-list mailing list