vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

So you have a dictionary after all!

Dictionaries are indexed by key and the keys are in a hash order for fast lookups. They will always display in this order! If you want to sort by a certain item, you have to convert them to lists. I thought that is what you did.

data_dict = {
'1234': ['Matt', '2.5', 'CS'], 
'1000': ['John', '4.0', 'Music'], 
'1023': ['Aaron', '3.1', 'PreMed'], 
'1001': ['Paul', '3.9', 'Music'], 
'9000': ['Kris', '3.5', 'Business']
}

# convert dictionary to a list of tuples
data_list = [(key, val) for key, val in data_dict.items()]

print(data_list)
"""the raw list -->
[
('1234', ['Matt', '2.5', 'CS']), 
('9000', ['Kris', '3.5', 'Business']), 
('1001', ['Paul', '3.9', 'Music']), 
('1023', ['Aaron', '3.1', 'PreMed']), 
('1000', ['John', '4.0', 'Music'])
]
"""

# now you can sort the list by item[1][1]
sorted_list = sorted(data_list, key=lambda tup: tup[1][1])

print(sorted_list)
"""result sorted by item[1][1] -->
[
('1234', ['Matt', '2.5', 'CS']), 
('1023', ['Aaron', '3.1', 'PreMed']), 
('9000', ['Kris', '3.5', 'Business']), 
('1001', ['Paul', '3.9', 'Music']), 
('1000', ['John', '4.0', 'Music'])]
"""

# however if you go back to a dictionary
new_dict = dict(sorted_list)

print(new_dict)
"""result is the dictionary order again -->
{
'1234': ['Matt', '2.5', 'CS'], 
'1000': ['John', '4.0', 'Music'], 
'1001': ['Paul', '3.9', 'Music'], 
'1023': ['Aaron', '3.1', 'PreMed'], 
'9000': ['Kris', '3.5', 'Business']}
"""

So, if you want to do any processing that needs a sorted order, to have to convert your dictionary to a temporary list.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A Python dictionary is an efficient way to store data and has very fast lookup speeds ...

# in Python you could use a dictionary key:val pair
# where the key is the integer index and val is the float
# if you just want to store values at an index

myarr = dict()

# load and store
myarr[45] = 2
myarr[619] = 3.465
myarr[36249] = 28.405

# retrieve val at index
ix = 619
val = myarr[ix]
print( "Value at index %d --> %s" % (ix, val) ) 

# this is a safer way to retrieve val at index
ix = 600
# if ix has not been loaded, use a default of 0.0
val = myarr.get(ix, 0.0)
print( "Value at index %d --> %s" % (ix, val) )

"""my output -->
Value at index 619 --> 3.465
Value at index 600 --> 0.0
"""

Sorry, didn't see pythopian's post of the same thing.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

This code snippet shows you how to sort more complicated objects like a list of lists (or tuples) by selecting an index of the item to sort by.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can also use a somewhat older concept of sorting, the Schwartzian transform algorithm. This is made very easy with Python's list comprehension ...

# sort a more complex combination of lists/tuples:
    
mylist = [
(1, ['a', '3.1', 'ad']),
(2, ['b', '4.0', 'bd']),
(3, ['c', '2.5', 'cd']),
]

# use the Schwartzian transform algorithm
# temporarily put a copy of indexed item in front
templist = [(x[1][1], x) for x in mylist]
templist.sort()
# remove temporary front item after sorting
newlist = [val for (temp, val) in templist]

print newlist

"""my result (made pretty) -->
[
(3, ['c', '2.5', 'cd']),
(1, ['a', '3.1', 'ad']), 
(2, ['b', '4.0', 'bd'])
]
"""
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

"Look, all I know is what they taught me at command school. There are certain rules about a war and rule number one is young men die. And rule number two is doctors can't change rule number one."
-- Henry Blake

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

"Ladies and gentlemen, take my advice, pull down your pants and slide on the ice."
-- Sidney Freedman

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Is that a question or statement? If it's a question then my answer is that I could only guess the enormous effort for preventing spam and keeping things in order. So us members know very little of what happens behind the scenes and can only guess the great efforts the moderators and administrators have put into daniweb.

Well said!

I guess I will have to vote for myself to get at least one vote.

lllllIllIlllI commented: I voted for you!! :P +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Similar to Gribouillis' code, but uses lambda as a helper function ...

# sort a more complex combination of lists/tuples:
mylist = [
(1, ['a', '3.1', 'ad']),
(2, ['b', '4.0', 'bd']),
(3, ['c', '2.5', 'cd']),
]
# sort by item at index [1][1] of each tuple
# using a helper function like lambda
newlist = sorted(mylist, key=lambda tup: tup[1][1])

print newlist

"""my result (made pretty) -->
[
(3, ['c', '2.5', 'cd']),
(1, ['a', '3.1', 'ad']), 
(2, ['b', '4.0', 'bd'])
]
"""
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

A hot bowl of chicken noodle soup and crackers.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can use one of the built-in string functions ...

n = 2
digits = 3
ns = str(n).rjust(digits, '0')

print(ns)  # 002
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I didn't know they took a video of me buying beer! :)

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Lord Aberdeen was quite touched when I told him
I was so attached to the dear, dear Highlands and
missed the fine hills so much. There is a great
peculiarity about the Highlands and Highlanders;
and they are such a chivalrous, fine, active people.
-- Queen Victoria

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If
remove('an', 'banana') --> 'bana'
then this should be
remove('iss', 'Mississippi') --> 'Missippi'
So you can use ...

def remove(sub, s):
    # replace first sub with empty string
    return s.replace(sub, "", 1)

# test
print( remove('an', 'banana') )        # --> bana
print( remove('iss', 'Mississippi') )  # --> Missippi

If you want to remove all subs, then use -1 in replace() which actually is the default value ...

def remove_all(sub, s):
    # replace all sub with empty string
    return s.replace(sub, "", -1)

# test
print( remove_all('an', 'banana') )        # --> ba
print( remove_all('iss', 'Mississippi') )  # --> Mippi

Python comes with a wealth of thoroughly tested string functions, might as well use them.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

It can be as simple as this ...

import os
import time

# pick a file you have in the working directory
filename = "beachball.jpg"

# show file creation time
print( time.ctime(os.path.getctime(filename)) )
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If the OP has not even given an example of what has been tried, I would prod them to at least give an idea of how they would approach the solution. Then you can give hints how to proceed.

Another way to help is to give a related example that would be a part of the solution. At least this way the OP gets involved in the quest to solve the problem.

If you had fun with the challenge to solve the problem, be a little patient and don't post your solution right away.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The Text widget of the Tkinter GUI toolkit is the start of a simple text editor. Here we explore how to get the line (row) and column numbers of the text insertion point ...

# explore Tkinter's Text widget
# get the line and column values of the text insertion point
# vegaseat

import Tkinter as tk

def get_position(event):
    """get the line and column number of the text insertion point"""
    line, column = text.index('insert').split('.')
    s = "line=%s  column=%s" % (line, column)
    root.title(s)


root= tk.Tk()
root.title('start typing')
text = tk.Text(root, width=40, height=10)
text.bind("<KeyRelease>", get_position)
text.pack()
# start cursor in text area
text.focus()

root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

As you slide down the banisters of life may the splinters never point the wrong way.
-- Irish Proverb

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The Now Generation will blame his parents, so where did his parents go wrong?

kvprajapati commented: Agree +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The best way to learn any computer language is to experiment with the concepts of the language, and if you are stuck, search the manuals and ask question on a language forum like this.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Its time to explore wxPython's wx.Timer() and wx.StopWatch() widgets. The stopwatch works in the background to track the length of a process ...

# explore wxPython
# wx.Timer() one_shot and wx.StopWatch() example
# a one_shot delays for a set time
# tested with Python25 and wxPython28 by vegaseat

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, mysize):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize)
        self.SetBackgroundColour('red')
        self.watch = wx.StopWatch()

        self.timer = wx.Timer(self)
        # interval = 2000ms (2 seconds)
        # default is oneShot=False, timer keeps restarting
        self.timer.Start(2000, oneShot=True)
        self.watch.Start()
        self.SetTitle("stopwatch started")
        # bind EVT_TIMER event to self.onTimer() action
        self.Bind(wx.EVT_TIMER, self.onTimer)

    def onTimer(self, event):
        # establish new color
        self.SetBackgroundColour('green')
        # clear old color, set to new color
        self.ClearBackground()
        # pause/stop the stopwatch and get its time
        self.watch.Pause()
        time = self.watch.Time()
        s = "stopwatch stopped at %s milliseconds" % time
        self.SetTitle(s)


app = wx.App(0)
# create a MyFrame instance and show the frame
MyFrame(None, '---', (500, 100)).Show()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If you put the number of primes you want, you called it x, in the outer loop range() you will get x numbers, but since not all of them are prime it will print less than x numbers.

You need to make the outer loop an endless loop with a counter and an exit condition to break out of the outer loop ...

i=1
x = int(input("Enter the number:"))

counter = 0
while True:
    c=0;
    for j in range (1, (i+1), 1):
        a = i%j
        if (a==0):
            c = c+1

    if (c==2):
        print (i)
        counter = counter + 1
        if counter >= x:
            break

    i=i+1

BTW, your coding style could be improved, but it's readable enough.

A note to lukerobi, 1 is not a prime number.

cmae commented: what is c for? +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Mantis shrimps have the most complex eyes in the animal kingdom. They can see in 12 primary colors, four times as many as humans, and can also detect different kinds of light polarization. The shrimp's cell membranes are rolled into tubes, which researchers hope could be mimicked in the lab using liquid crystals. This would greatly increase the information obtained from a DVD sensor using such technology.

http://news.yahoo.com/s/nm/20091025/sc_nm/us_shrimp_dvds_1

GrimJack commented: You have wowed me! thanks +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Check the spelling of getPos()

thehivetyrant commented: Dedicated to helpfulness! thanks +1
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

What you have in your class right now are functions, not methods. You can turn your functions into methods with 'self'. This way you can also avoid globals outside the class, like your method list.

scru commented: why oh why did I not see that? +4
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Write a program that gives the weekday you were born.

Write a program that tells you many days old you are.

Write a program that lists the date of the third Wednesday of the month for the whole year.

Write a program that gives the difference in days between two given dates.

Dating is fun!

Just a note:
The DevCpp IDE and GNU compiler package is still available at:
http://sourceforge.net/projects/dev-cpp/files/
I installed (Windows XP):
devcpp-4.9.9.2_setup.exe
(about 8.9 MB download)
If you have Vista there are of course special considerations, see:
http://www.cs.okstate.edu/~katchou/devcpp-vista-dirs/devcpp.htm

Also, if you use Linux, there is a version of DevCpp:
devcpp-bin_070.tar.gz
at the same site:
http://sourceforge.net/projects/dev-cpp/files/

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

One way to display a colorful message with the ever so popular PyQT GUI toolkit (works with Python2 and Python3) ...

# show a colorful splash message for a set time then quit
# tested with PyQT45  by  vegaseat

from PyQt4.QtCore import *
from PyQt4.QtGui import *

def do_html(text, color='black', size=3):
    """create a line of html code for text with color and size"""
    sf = "<FONT color=%s size=%d>%s</FONT>"
    return sf % (color, size, text)

# build up simple HTML code ...
# text between <B> and </B> is bold
# <BR> inserts a line break (new line)
html = ""
html += '<BR>'
orange = "#FFBA00"  # gives a better orange color
color_list = ['red', orange, 'yellow', 'green', 'blue']
ix = 0
for c in 'WE LOVE RAINBOWS':
    # make character c bold
    c = "<B>" + c + "</B>"
    if ix >= len(color_list):
        ix = 0
    html += do_html(c, color_list[ix], 7)
    ix += 1
html += '<BR>'

# create a QT GUI application
app = QApplication([])
label = QLabel(html)
# show label without frame
# comment line out if you want a frame
label.setWindowFlags(Qt.SplashScreen)
label.show()
# show for x milliseconds, then quit
x = 5000
QTimer.singleShot(x, app.quit)
app.exec_()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can create rather colorful text using html code and wxPython's wx.html.HtmlWindow widget. Here we use a small function to help us generate html code ...

# use wxPython's wx.html.HtmlWindow to create colorful text
# tested with Python25 and wxPython28  by  vegaseat

import wx
import wx.html

def do_html(text, color='black', size=3):
    """create a line of html code for text with color and size"""
    sf = "<FONT color=%s size=%d>%s</FONT>"
    return sf % (color, size, text)


# build up simple HTML code ...
# text between <B> and </B> is bold
# <BR> inserts a line break (new line)
html = ""
html += do_html("Create colorful text ", "red")
html += do_html("with html code to be", "blue")
html += '<BR>'
html += do_html("displayed in wxPython's ", "green")
html += do_html("wx.html.HtmlWindow", "brown")
html += '<BR><BR>'
orange = "#FFBA00"  # gives a better orange color
color_list = ['red', orange, 'yellow', 'green', 'blue']
ix = 0
for c in 'WE LOVE RAINBOWS':
    # make character c bold
    c = "<B>" + c + "</B>"
    if ix >= len(color_list):
        ix = 0
    html += do_html(c, color_list[ix], 7)
    ix += 1


# set up the GUI window/frame ...
app = wx.App(0)
mytitle =  "wx.html.HtmlWindow for colorful text"
width = 420
height = 160
# make parent None
frame = wx.Frame(None, id=-1, size=(width, height), title=mytitle)
# create an html label/window
htmlwin = wx.html.HtmlWindow(parent=frame, id=-1)
# display the html code
htmlwin.SetPage(html)
frame.Show(True)
frame.Center()
app.MainLoop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Access a dictionary directly ...

# a food:price dictionary
food_dict = {
'soymilk' : 3.69,
'butter' : 1.95,
'bread' : 2.19,
'cheese' : 4.39
}

# pull one key item like 'bread' out of the dictionary
print("Bread = ${bread:4.2f}".format(**food_dict))  # Bread = $2.19
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Since Employee is inherited by Calc it also inherits method get_details(). So use this method with the instance of Calc. You need to keep track of the instance with 'self' ...

class Employee(object):
    name = ' '
    def get_details(self):
        self.name = input('Enter the employee name ')
        print("In super class-->", self.name)


class Calc(Employee):
    def pr(self):
        print("In sub class==>", self.name)


if __name__=='__main__':
    y = Calc()
    y.get_details()
    y.pr()
    # create another instance
    y2 = Calc()
    y2.get_details()
    y2.pr()

Note: by convention class names are capitalized so you can trace them easier. Also, this is Python3 code!

python.noob commented: Really nice effort +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The function input() in Python3 replaces the old Python2 function raw_input() and returns a string,so you have to use int() to convert the string to an integer value ...

def main():
    celsius = int( input("What is the temperature in celsius? ") )
    fahrenheit = (9.0 / 5.0) * celsius + 32
    print('The temperature is', fahrenheit, 'degrees Fahrenheit.')

main()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Let's assume you want something like this ...

x = 123.456

ipart, fpart = str(x).split('.')

print ipart, fpart
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Against stupidity; God Himself is helpless.
-- nice Jewish proverb

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

I ask not for a lighter burden, but for broader shoulders.
-- Jewish proverb

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If everything seems to be going well, you have obviously overlooked something.
-- African proverb

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

This code also works with Python3 ...

# explore module ctypes to get mouse position
# tested with Python 2.5.4 and Python 3.1.1

import ctypes as ct

class GetPoint(ct.Structure):
    _fields_ = [("x", ct.c_ulong), ("y", ct.c_ulong)]

def get_mousepos():
    pt = GetPoint()
    ct.windll.user32.GetCursorPos(ct.byref(pt))
    return int(pt.x), int(pt.y)

print( "Mouse position at start of program:" )
print( "x=%d, y=%d" % get_mousepos() )
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Waiter, there's a fly in my soup!
Don't worry sir, the spider on your bread will catch it.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Here is typical code that I use with the py2exe module to convert Tkinter programs to an executable package for Windows computers ...

"""
Simple py2exe version used for Tkinter programs.
Run this program to create a windows exe file with py2exe.
Run it in a folder that als contains your source code file.

It will create 2 folders named build and dist.

The build folder is temporary info and can be deleted.

Distribute whatever is in the dist folder.

Your library.zip file contains your optimized byte code, and all
needed modules.  This file together with the Python interpreter
(eg. Python25.dll) should accompany the created executable file.
Note that you might be able to share this large library file with
other Python/Tkinter based .exe files.

The MSVCR71.dll can be distributed and is often already in the
Windows/system32 folder.

w9xpopen.exe is needed for os.popen() only, can be deleted otherwise.
"""

from distutils.core import setup
import py2exe
import sys

sys.argv.append("py2exe")
sys.argv.append("-q")

# insert your own source code filename below ...
code_file = 'Tk_ParResist1.pyw'

# replace windows with console for a console program
setup(windows = [{"script": code_file}])

Should work with Python26 if you installed the proper py2exe module. Since Python26 uses a different C compiler, msvcr71.dll changes to msvcr90.dll and of course the interpreter is Python26.dll.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
marshall31415 commented: very helpful +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Ah, the ever so popular Tkinter GUI toolkit. This is the code to get size (width x height) and position (x + y coordinates of the upper left corner of the window in the display screen) information of the Tkinter root window ...

# show width and height of Tkinter's root window
# vegaseat

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
w = 460
h = 320
x = 150
y = 100
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (w, h, x, y))

# update is needed
root.update()
geo = root.geometry()
print(geo)                    # 460x320+150+100
width = root.winfo_width()    # 460
print(width)
height = root.winfo_height()  # 320
print(height)

root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Honesty is the best policy, and if that doesn't work, use the second-best policy.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

The main reason Santa is so jolly is because he knows where all the bad girls live.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Creating a simple shadow effect around a Tkinter frame ...

# create a frame with a shadow effect border
# using overlapping frames
# vegaseat

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

root = tk.Tk()
w = 320
h = 220
x = 150
y = 100
# use width x height + x_offset + y_offset (no spaces!)
root.geometry("%dx%d+%d+%d" % (w, h, x, y))
root.title("shadow effect border")

frame1 = tk.Frame(root, bg='grey', width=w-30, height=h-30)
frame1.place(x=20, y=20)

frame2 = tk.Frame(root, bg='yellow', width=w-30, height=h-30)
frame2.place(x=10, y=10)

root.mainloop()
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

You can not do it in the function you are calling, because the variable is now chosenCategory and the function does not have the information that this variable used to be called sports or whatever.

So my suggestion is to make the category string the first item in the tuple and then use a slice of the tuple for normal use ...

def build_html(chosenCategory):
    filename = '%s.html' % (chosenCategory[0])     
    return filename

# test
# make the category string the first item in the tuple
sports = ('sports', ('AFL', 6L), ('American Football', 2L))

fname = build_html(sports)

print fname  # sports.html

# to use the tuple for its values slice out the category name
print sports[1:]  # (('AFL', 6L), ('American Football', 2L))
qadsia commented: Worked perfectly :) +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

Q: "What did the lawyer name his daughter?"
A: " Sue."

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

In the spring of 2002, at New York's Kennedy airport, an individual later discovered to be a public school teacher was arrested trying to board a flight while in possession of a ruler, a protractor, a set square, a slide rule, and a calculator.

At a morning press conference, Attorney General John Ashcroft said he believes the man is a member of the notorious "Al-Gebra" movement. He has been charged by the FBI with carrying weapons of math instruction.

~s.o.s~ commented: If this is an original, you sure have a strong funny bone :-) +0
iamthwee commented: kill those towel heads +0
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

If the #2 pencil is the most popular, why is it still #2?
-- quoted question by the late George Carlin

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

In a dictionary container the 'potato' : 'pomme dé terre'
key:value pair will work well after the language swap.

If you have several English words for one French word you need to use a tuple container as a value. Tuples can be used for keys on a swap. Then in your key search you have to go through the items in the tuple one by one, if the key type is a tuple.

This project can quickly become rather complex, no matter what approach you pick. If you have a choice of words to pick from, you need the know the language by heart, or at least the meaning of the word in the sentence it is used in!

George Carlin used to make a lot of money explaining the quirks of the English language. I imagine he had a counterpart in France.

jbennet commented: pretty decent explaination +21
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

This Python code allows you to get selected statistics of a story text. It will count lines, sentences, words, list words and characters by frequency, and give the average word length. It should be easy to add more statistics using the dictionaries created.

vegaseat 1,735 DaniWeb's Hypocrite Team Colleague

As a hint, here is a slow but simple prime number algorithm ...

# slow and simple algorithm to find prime numbers
# prime numbers are only divisible by unity and themselves
# (1 is not considered a prime number)

limit = 20
# 2 is the first prime number
plist = [2]
for n in range(3, limit):
  for x in range(2, n):
    if n % x == 0:
      break
  else:
    # this else has to line up with the inner for, not the if
    # implies that the loop fell through without finding a factor
    #print n, 'is a prime number'  # test
    plist.append(n)

print "prime list  =", plist
print "list length =", len(plist)
print "third prime =", plist[2]
print "last prime  =", plist[-1]

"""my result -->
prime list  = [2, 3, 5, 7, 11, 13, 17, 19]
list length = 8
third prime = 5
last prime  = 19
"""

You could set the limit higher to get to the 1000th prime number in the list. It will take time. There are clever ways to improve the speed, but I leave that as an exercise. Also check if there is a relationship between the minimum limit and the size of the prime number list.