15,185 Topics

Member Avatar for
Member Avatar for 1989sam

I have these 3 string: YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs YELLOW,SMALL,STRETCH,ADULT,Tdsfs YELLOW,SMALL,STRETCH,ADULT,TD I would like to remove everything after the last "," including the comma. So i want to remove these parts ",T21fdsfdsfs" ",Tdsfs" and "TD". How could i do that in Python?

Member Avatar for seanbp
0
105
Member Avatar for xtra333

Hi people. I am having trouble printing out a list of items with n items per line. Here is my current code. [CODE]def printList(lst, lineCount): # given a list of items, print it out in # lineCount items per line. count=0 strList= '[ ' for element in lst: strList = …

Member Avatar for richieking
0
146
Member Avatar for Banjoplucker

Please look at my code at: [url]http://www.bpaste.net/show/11961/[/url] I appear to have gone down a "blind alley" here. Having identified the location of the Word perfect headers, I need to verify that they are indeed genuine by reading the hex value 10 bytes from the beginning of the header. If it …

Member Avatar for richieking
0
118
Member Avatar for Gribouillis

This snippet generates the best rational approximations of a floating point number, using the method of continued fractions (tested with python 2.6 and 3.1).

Member Avatar for Gribouillis
1
1K
Member Avatar for twohot

This issue is probably discussed before. However, I can still use a little insight. I am a python beginner looking to develop a small client/server suite. The clients will reside in different PCs across a LAN and their job is to recieve a file (say, a .txt file) from the …

Member Avatar for woooee
0
115
Member Avatar for hbluthi

I'm making a Card class and need to make sure that the suit is valid. When I call on the Card class and construct one setting the suit to 'Jordan' it actually ok's that suit and prints 'Ace of Jordan'. Instead it should become the default, of Spades. What am …

Member Avatar for hbluthi
0
654
Member Avatar for Oldguy1

Hey I'm very new to the programming world, and what i am trying to do is produce a Koch Snowflake via turtle from python2.5. this is what I have so far... [CODE] from turtle import * def snowflake(lengthSide, levels): if levels == 0: return forward(lengthSide), right(120), forward(lengthSide), right(120), forward(lengthSide) forward(lengthSide) …

Member Avatar for ohernandezmit
0
3K
Member Avatar for robm612

Ok guys so i am trying to create 2 versions of a program which sorts items into boxes. The first version i have to create puts the item weights (integer between 1 and 20) into the first "box" they will fit into. So given the input 11,17,3,5,4 the list the …

Member Avatar for TrustyTony
0
145
Member Avatar for tk-421

Monday morning, our final exam is to write a Python program according to whatever the teacher will throw at us. Any ideas as to how or WHAT to study to be ready for anything? (Most of the class expects to fail this, btw. I don't want to be among those …

Member Avatar for Gribouillis
0
95
Member Avatar for Naynah

I have to create all the method signatures in the ResizableArrayList and then fill it in with comments. And each method is supposed to be blank with a return null or --1. How do i do this?

Member Avatar for richieking
0
105
Member Avatar for jozz3

I am working on a program with classes and a main function. This game involves tanks moving around a grid of defined size, and shooting at each other. Each tank has a name, armour and firepower. On the grid, there are randomly generated squares that contain extra armour or firepower. …

Member Avatar for taskkiller
0
122
Member Avatar for polanski

Hey everyone, new here. I'm looking for a little help with my program. Its supposed to take a txt file called test.txt, and removes all spaces trailing at the end of lines. ex. (note the spaces) "python " -> "python" "daniweb is great" -> "daniweb is great" " forum" -> …

Member Avatar for richieking
0
159
Member Avatar for convoluted

Hope you kind folk can spare a bit of advice. I'm trying to find a clever way to modifying a part of an image without replacing the image completely. For instance, let's say I have an image of a car and I would like to show the tire is flat. …

Member Avatar for richieking
0
174
Member Avatar for Hawkeye Python

Hello :) I'm from Brazil, so sorry about my english. This is the first code I post here - I'm a begginer in Python. It is a function to calculate determinants of matrices. You can attach it to a class if you wish. Please leave a comment if you wish …

Member Avatar for Gribouillis
0
3K
Member Avatar for Naynah

I'm a Python semi-beginner and i have to do a prac but the problem is i've totally forgetten how to do it! Can you please help me get started with part 1 even if its just 1.a because every time i tried to get it to work it keeps saying …

Member Avatar for Naynah
0
162
Member Avatar for HoneyBadger

Guys, how do I add an item to a list using a loop? My loop in a nutshell does this: [CODE]for w in book_line.split(" "): word_list = [] if w != "": word_list.append(w.lower()) return word_list[/CODE] While experimenting with this I got mainly two results: 1.) When I use return word_list, …

Member Avatar for HoneyBadger
0
3K
Member Avatar for KMC

Hello, I am completely stuck on a question I was assigned and was hoping for a little guidance to get me started. The question is: Create a program that outputs the molar mass of a molecule. The user will enter a molecule with each atom individually (CO2 would be entered …

Member Avatar for KMC
0
76
Member Avatar for patrickgormally

Hi! I am trying to do a project in which I draw a Christmas tree with about 3 segments, filled in with color and with writing below it saying "Merry Christmas". Sadly, I have no idea where to being! I'm able to draw the Christmas trees using stars by defining …

Member Avatar for woooee
0
3K
Member Avatar for xtra333

Hello. My instructor want me to write a magic Square code. And here is what the square is supposed to print: 11 18 25 2 9 10 12 19 21 3 4 6 13 20 22 23 5 7 14 16 17 24 1 8 15 Here is my current …

Member Avatar for woooee
0
121
Member Avatar for patrickgormally

I am reading a text file inside Python that contains salaries and the raise they will receive as a percent. I am trying to multiply the initial salary by the percent and print the salary after the raise has been applied. I keep receiving an error message which is as …

Member Avatar for patrickgormally
0
3K
Member Avatar for longlongsilver

i have my code and i want to cycle through the following colors blue green orange red yellow. i got blue but i dont know how to the rest [CODE]from Tkinter import * myfont = ("Arial", 1, "bold") window = Tk() window.title("grid") window.geometry("500x420") frame = Frame(window) frame.grid() button0 = Button(frame, …

Member Avatar for richieking
0
306
Member Avatar for HoneyBadger

Guys I have a text file, and I am trying to get my program to focus on a specific part of the text. How would I do that? I tried this to no avail: [CODE]f = open("book.txt") f.readlies()[10:3340][/CODE]

Member Avatar for TrustyTony
0
106
Member Avatar for sc2player

Hi I was wondering how to extract info from a data file, and place it in a dictionary. Say you're given a file, in the following format: [CODE]tomCruise # Username Tom Cruise # Name Los Angeles, CA # Location http://www.tomcruise.com # URL Official TomCruise.com crew tweets. We love you guys! …

0
110
Member Avatar for Elanosaurus

For my python class i have to make a game, i decided to make a simon sort of game. I'm not allowed to use any outside modules; for instance pygame. I have most if not all of the visuals done. But there are two main issues: - One issue is …

0
57
Member Avatar for M3M69

i have this code that reads a file and strips out all the non essential stuff and then i want to make a dictionary for the actors and films they have been in .. i do that but it keeps on telling me that actors isnt defined ... how am …

Member Avatar for winmic
0
87
Member Avatar for testie

Hey guys, this code is supposed to remove all the spaces at the end of each line. However from what I can tell it prints out the exact same file again instead of removing nothing. Have I been using the wrong test files? Or is there something wrong with my …

Member Avatar for richieking
0
103
Member Avatar for bretthay93

i want to make a program that has a player take on the computer in a game of Rock Paper Scissors. The GUI should have an appropriate lable at the top. it should allow the player to select his or her weapon of choice. program should have a fight button …

Member Avatar for bretthay93
0
312
Member Avatar for HoneyBadger

It's been a while since I bugged you guys. But I need the council of my wise advisers once more. I am trying to write a program that reads a .txt file, breaks each line into words, strips the whitespace and punctuation from the words and returns them in lowercase. …

Member Avatar for HoneyBadger
0
97
Member Avatar for Thropian

I making a game that would use multiple canvases drawing on one canvas then switching to another... is there any way to get a new canvas and be able to restore the old canvas with the drawings still on it?

Member Avatar for Thropian
0
199
Member Avatar for nejger

Hello! Now I have written a function for numbers over 3999: if arabicnumber<=3999: print arabToRom else: parenthesis=0 while (arabicnumber)>3999 arabicnumber/=1000 for i in range (parenthesis... etc and i compare all the numbers that i write in so if i write like 5560 it pirints out ( V ) and the …

Member Avatar for woooee
0
105

The End.