GIDForums  

Go Back   GIDForums > Computer Programming Forums > Python Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-Feb-2008, 13:32
fonz87 fonz87 is offline
New Member
 
Join Date: Jan 2008
Posts: 12
fonz87 has a little shameless behaviour in the past
Smile

A program that deletes the duplicate numbers



I'm trying to write a program that deletes the duplicate numbers. For example if I enter 1 1 2 4 5 7 2
I should print 1 2 4 5 7
This is what I have so far, I don't know how to get rid of the duplicates

Python Code:
import string
import math
def main():
    x = raw_input("Enter a number")
    mylist = []
    sentinel = "-1"
    while (x!=sentinel):
        y=eval(x)
        mylist.append(y)
        mylist.sort()
        x = raw_input("Enter a number")   
    print mylist [0:3]
       
main()
Last edited by admin : 23-Feb-2008 at 16:44. Reason: Please insert your example Python codes between [PY] and [/PY] tags
  #2  
Old 29-Feb-2008, 11:53
crystalattice's Avatar
crystalattice crystalattice is offline
Flame War Instigator
 
Join Date: Apr 2004
Location: San Diego
Posts: 1,539
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

Re: A program that deletes the duplicate numbers


Take a look at the string processing functions and the list manipulation functions. One of those two should have something that helps.

(Sorry I can't be more specific. I don't have my Python books available right now and I can't remember the exact methods you can use.)
__________________
Common Sense v2.0-Striving to make the world a little bit smarter.
 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
floating point decimal to ascii conversion crazypal C Programming Language 5 18-Apr-2007 04:59
Re: Command Line Arguments, Part 2 WaltP C Programming Language 3 25-Feb-2006 01:14
Re: Beginning Python Tutorial (Part 4) crystalattice Python Forum 0 02-Sep-2005 21:44
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 17:36

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:11.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.