153 Posted Topics
Re: maybe I'm misunderstanding, but wouldn't something simple like [CODE]def make_norm_lis(entry): lis=[] for letter in entry: if letter.isalpha(): lis.append(letter) else: lis.append(' ') lis=''.join(lis) lis=lis.split() return lis[/CODE] work? [CODE]>>> st='!@#this@#$is//sparta' >>> print(make_norm_lis(st)) ['this', 'is', 'sparta'] >>> >>> work='i.going.to.work' >>> >>> print(make_norm_lis(work)) ['i', 'going', 'to', 'work'][/CODE] | |
Re: There's a sticky on beginner project ideas at the beginning of the forum. Check 'em out. Also there are a couple [URL="http://www.daniweb.com/software-development/python/threads/257510"]more advanced projects here.[/URL] | |
Re: Don't bump old threads...start a new thread with your problem. | |
Re: Why wouldn't you just want the list??? Is it just a matter of printing? If not why not just return a list of integers??[CODE]>>> def renum(lis): return [int(num) for num in lis] >>> a=['1','2','3'] >>> >>> b=renum(a) >>> b [1, 2, 3][/CODE] | |
Re: Also, I tried this with a file someone else posted here a couple days ago, it had a different format, but I feel the idea here is the same, the way I broke it down is just different because of the format:[CODE]File: 115 139-28-4313 1056.30 135 706-02-6945 -99.06 143 595-74-5767 … | |
Re: Post code and ask specific questions, read forum rules and/or pytony's signature. | |
Re: well I've never used graphics but I've used livewires;though I must admit very rarely, however maybe showing you what this "with only one falling snowflake for now" would look like with livewires:[CODE]from livewires import games games.init(screen_width=400, screen_height=400, fps=60) flake=games.load_image('snowflake.png',transparent=True) cabin=games.load_image('snowy_cabin.jpg',transparent=False) games.screen.background=cabin class Snow(games.Sprite): def update(self): if self.bottom>games.screen.height: self.y=games.screen.height/20 snow=Snow(image=flake, x=games.screen.width/2, … | |
Re: Show us some effort, if you've been working on it for three days you must have some code, post it. And use the code tags when you do. Also read the forum rules. | |
Does anybody know how to clear all widgets; labels, buttons, etc. from a tkinter frame so that new ones may be put in their place? I've tried self.destroy() but that makes the frame unreachable, and self.grid_forget() followed by, "and without" self.grid() neither of these work, at least not as expected. … | |
Re: ohhh tony and his one-liners ;-) also, I'm not sure why you thought checking phonebook.items was the most prudent style...I hope you already know what's wrong with that choice; why not phonebook.keys()? | |
Re: Among several other things, you're not telling python to do with that file your opening, you're not going to like the output, how about open(file,'r')... | |
Re: I'm going to over complicate the matter,as to show you step by painful step how the process goes, in my mind that is. I'm not going to make functions either, let's see you re-engineer my code, and hopefully simplify it. Also, post your result. "Note that help.txt was a copy … | |
Re: Don't bump old threads, particularly old solved threads...this one is six years old for goodness sake... | |
![]() | Re: so you know, the function you created doesn't need the parameter word, but if you were abstracting the function, which is often considered better; you could make it something sort of like: [CODE]def no_e(word): noe=word.replace('e','') return noe[/CODE] and then iterate through the words in the file and no_e them. my … |
Re: This is not the place to start python my friend. It's a very easy language to learn, I suggest you check out our Starting Python sticky thread, and there are tons of books on learning python, many of them free. And I've heard Bucky, at thenewboston has a great set … | |
Re: also use code tags when posting code. And as woooee said, this isn't doyourhomeworkweb it's Daniweb, read the forum rules. | |
As most of us know in tkinter in order to properly display an image it must be assigned to a variable, however what if you don't know that amount of images that are going to be necessary? i.e. A friend list, how would one display the friends pictures? | |
I'm trying to utilize partial in order to bind an image to it's associated name in a list "you'll see what I mean" but I'm getting a TypeError thrown on it, this is my first time trying to work with partials so I'm just not quite sure what's going on: … | |
Re: Worked fine for me, line 6 "guess= list(guess)" was unnecessary, when you split it, you're splitting the string into a list. Also, how are you going to account for user error? ie. what if I entered: Shoot: f7, c4, c3, b1, a1 | |
Re: Rev Jim is right, check your algorithm, when you're simply assigning each of them to a random number there's no guarantee that they will all be different. [ICODE]Have an empty array while the length of the array is less than six generate a random number if that random number isn't … | |
Re: hit the (CODE) button/tags before you post code, also your strategy for the key is awful...I don't understand why you would do:d=len(phbuk);phbuk[d+1]=name How about something more like: `phbuk[a]=abc #"or [b,c] depending on your preference"#` > Now if i want to delete a particular record just by giving name then how … | |
Re: Here's a little help to get the juices flowing, but for the future you need to show effort around here [B][U]take heed of Ezzaral's edit notes[/U][/B] and read that thread, or for a quicker review of what he's talking about read [U][URL="http://www.daniweb.com/software-development/python/threads/359823"]pytony's signature[/URL][/U][CODE]def mult_table_numbers(): alpha = int(input('Starting: ')) omega = … | |
Re: You can't just drop off your homework assignment and expect us to do it for you, put some effort in and we'll help you figure out issues. | |
Re: Tcll, as you should know people are much less likely to reply to "solved" threads, we also don't like old ones bumped up, just start a new thread. | |
Re: Python comes with an IDE called IDLE; I'd suggest reading the beginner threads and also decide which version of python you're going to start with, python 3.2.2 is the most recent version, there are more packages available for python 2.7 but the future is python 3; python 3 is backwards-incompatible … | |
Re: You were thinking in the right direction, you just weren't actually doing anything: I'll give you heavy help on one of them and the idea should become quite clear for all of them. [CODE]>>> word=input('word: ') word: hello >>> word3='' >>> for letter in word[::-1]: #which could also be "for … | |
Re: :) well just so ya know there is a random module with things like shuffle.[CODE]import random f=open('names.txt','r') names=f.readlines() f.close() selected_names=set() while len(selected_names)<5: random.shuffle(names) indx=random.randint(0,len(names)-1) selected_names.add(names[indx])[/CODE] a set will get rid of any duplicates. but you could also do a "if key not in list" kind of thing:[CODE]selected_names=[] while len(selected_names)<5: random.shuffle(names) … | |
Just fooling around I came across an issue updating a digital-clock like label. This: [CODE]self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock=ttk.Label(self,text=self.now) self.clock.pack() while True: self.now=time.strftime('%a. %b %d %Y %H:%M:%S',time.localtime()) self.clock['text']=self.now[/CODE] simply freezes the program, I've managed to get it to update on certain events like the user hitting a button but … | |
Re: here's an interesting article on the subject "I didn't even know about CubicWeb before it" [URL="http://www.itworld.com/software/192113/pillars-python-six-python-web-frameworks-compared"]http://www.itworld.com/software/192113/pillars-python-six-python-web-frameworks-compared[/URL] |
The End.