15,179 Topics
| |
Guys I am trying to check the size of a item inside a list. How do I search through a list and return items of a certain size? This is what got: [CODE]#This is meant to search through a .txt file an return the words with 20 characters fin = … | |
[CODE] def main(): #Check to see if quickdraw is located in the correct palce quickfile = file_existance() quickdraw = subprocess.Popen(['java', '-jar', quickfile], stdin = subprocess.PIPE) #Intro, explaining what will occur throughout program intro() # x_coordinate(1) y_coordinate(1) initial_ball(quickdraw) def file_existance(): filename = raw_input("Please enter the name of the file: ") while … | |
I wrote the following function in Python3 for finding the largest product of numbers along the diagonal(top-left to right-bottom). [CODE=python] def GreatestOnDiagonal(data): '''Returns greatest product possible by multiplying 4 numbers in the diagonal ''' grtProduct=1 for item in data: for n in item: product=1 for r in range(0,4): try: d=data.index(item)+r … | |
Hi. I'm very new to python and I'm trying to write something that is conceptually very simple but I'm not sure how to approach it in python. I have 2 files, and basically want to open one file, and replace the content with something in another file. Example: file1.txt only … | |
Guys, I am trying to sort a list. But Python does not let me set my new sorted list into a variable. here: [CODE]list1 = ['a', 'z', 'b', 'y'] sorted_list = list1.sort() return sorted_list[/CODE] When I run this on my interpreter, instead of printing my string sorted, it prints "None" … | |
I'm new to Python, so bear with me..... I'm calling the Dislin plotting package from python to plot in a wxPython panel. This works OK but the plot gets grayed out when another window is moved over it. There is a Dislin function, sendbf, which updates the graphics window with … | |
Hi, I am new in python and programming basically. I have a code that compare 2 files by the first column and prints a file with the common lines. But i need it to compare the first 3 columns and print the file. I kind of have and idea of … | |
Since Django is not yet compatible with Python 3, what are other good web application development frameworks compatible with Python3? | |
Hi all, Ive been working on this little piece of code down there that removes the odd numbers from a list of numbers. I get an "IndexError: list index out of range" whenever I try to run it. From what I understand, it means that l[i] is attempting to use … | |
Hi, I am trying to split a string and return specific words. I know that using string.split() turns the string into a list of specific words. But how would I go about returning specific words? like the ones that contain certain letters? This is my code so far: [CODE]def e_words(m): … | |
Well that someone would be me. I finished three quarters of C, one quarter of Java, and one quarter of Python at my community college. I think it's about time that I start contributing something to a project, but I have no idea what I want to do. I tried … | |
Hello, I'm new to python world (I had only programmed on Visual Basic or Delphi), right now I'm doing a program on ironpython studio in wich I need to switch between forms. The thing is that I don't know where and how to initialize "form2" from "form1" to call it. … | |
The first time my code loops through my nested while loop it works. But the second time it doesn't- I don't know why. Could someone tell me the reason. [CODE]m = [['__', '__', '__'],['__', '__', '__'],['__', '__', '__']] z=1 count=9 f=[0,2] from random import choice w=choice(f) from random import choice … | |
I need to define a function that translates an sentence from present to past. A. put all words in lower case and omit all punctuation B. Plural and singular verbs should be recognized C. verbs ending in "y" change to "ied" D. verbs ending in "e" add "d" E. other … | |
Is there a way in python to look through a file line by line and find a word in that line, but only if the word is the first word in the line? Like if it was looking for the word "apple" then it would only notice if the line … | |
Hi, how do I write a list to a file on mac os x? I have tried everything..... file = open('test.txt', 'w') mylist = ["rocks","box"] file.write("This doesnt work either") file.write(str(mylist)) | |
Hello everyone, i faced some problem i cannot solve myself so any help would be appreciated. so here is the task. i have an integer, for example 123. then i want to simulate backspace pressed 3 times and then i want to simulate keyboard presses 1 2 and 3 and … | |
I need to write a Python Turtle graphics program to output an n-pointed regular star, where n is an odd integer from 5 -to- 99 input by the user in answer to a question prompt. Also, my program should NOT contain separate code for each different star please help! ASAP!! | |
Hi guys, I am trying to iterate through a list. This is my code: [CODE] #assume this is the list: list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] def iter_list(a): for s in a: return s #here it is when it runs: print iter_list(list1) a [/CODE] why doesn't it … | |
Hello there everyone basicly im a new student who has just started studying computing i was wondering if i could make a program to block access to some webpages for example [url]www.bbc.co.uk[/url] so if the user types in [url]www.bbc.co.uk[/url] in the adress bar i want my program to display access … | |
I just want to know if this is done right. And some suggestions on the commented line. [CODE]msg = ... import re msg = re.sub("[^\w ]", " ", msg) names = [] for x in msg.split(): if (x[0].isupper()) and not (x[1].isupper()):# I think this should be done in a different … | |
Hi. I'm new in python and I need some help. I need to make a program that does this: You put in a sentence, then the program puts it in a list. Words can be with one or more spaces; if there are more than one, the program should recognize … | |
Wget is a very useful tool, however, I dont know how to use it in python. Below is my try but with no luck. Would you tell me the right way ? Thank you very much !! I made a wwget.py [CODE] #!/usr/bin/python import urllib2, urllib img=wget("http://blog.freetimegears.com.tw/patrick/archives/Maple-tree.jpg") [/CODE] Running in … | |
Here I am required to use REGEX to do the stock price program, yet I found it almost impossible for me to do, I can only deal with for loop. '''Parse Stock prices. Create a function that will decode the old-style fractional stock price. The price can be a simple … | |
[CODE]red_ratio=int(factor/red_average(pic)) for pixel in pic: red=media.get_red(pixel) if red*red_ratio>=255: new_red=255 elif red*red_ratio<255: new_red=red*red_ratio media.set_red(pixel,new_red)[/CODE] ''Adjust the pixels of that Picture so that the average red value of the Picture is the same as the integer value provided.''' i cant figure out why scale_red gives me 0 instead of 100 | |
ONE '''you are given two file names: fin: the input file, and fout:the output file. The argument maxlen is an integer > 2, indicating the maximum length of each line in the output file. the function will read the fin as a text file line by line, and depending on … | |
from Tkinter import * import sys Root=Tk() RTitle=Root.title("Windows") RWidth=Root.winfo_screenwidth() RHeight=Root.winfo_screenheight() Root.geometry("%dx%d")%(RWidth,RHeight)) mainloop() Hello. When I run this code the window takes up the entire screen(win7).but remains below the bottom of the window portion of the taskbar. Even if the screen size is changed automatically carry out this.According to the height … | |
Hi, I need some assistance trying to delete elements in list. Your task is to write a function, called bawdlerize(<sent>, <word>), which removes an unsavory word, <word>, from a sentence, <sent>. Use the "del" operator on lists for this function. Example: s = ["now", "is", "the", "time", "for", "all", "good", … | |
Here some experiments to pretty print polynomials with help of vegaseat's tip of wx.lib.fancytext. | |
im creating a 2d side scroller in my class, and i have a image list out of a sprite sheet. and when the player goes forward the images show up fine, but i cant seem to get each image to flip when the player turns around and goes back, any … |
The End.