15,406 Topics
![]() | |
It won't work! [CODE]def get_user_choice(): from string import digits user_choice = input('Type a number, 1 to 6.\n\n') if user_choice == '': print 'Not a valid choice.' raw_input() main() check_if_true(user_choice) def check_if_true(): import random comp_choice = random.randint(1,6) if comp_choice != userchoice: print 'The computer won :(' return comp_choice, user_choice else: print … | |
hey guyz, i need to make a code for searching the names in the list txt. i pretty much got the other parts, but when im kinda stuck on searching. [CODE] def main(): list_of_names = open_file() print""" --------------- non sorted---------------------""" print_names(list_of_names) print """ ----------------sorted-------------------------""" list_of_names = sort_names(list_of_names) save_file(list_of_names) search_names(list_of_names) def … | |
Hi, I'm trying to write a hangman game program, but some things aren't working properly. [CODE]def hangman(): choice=input("Enter a letter: ") a=type.find(str(choice)) if len(choice)>1: print ("Only one letter please") hangman() elif a!=-1: b[a]=str(choice) print ("Correct") c=''.join(b) print (c) if type==c: print ("WINNAR!") else: hangman() else: d+=1 e[d]=choice if d==0: print … | |
Hi everybody, I just started learning pyqt.. I referred it's wiki page and found some but only two links are useful.. I finished pyqt tutorial in zetcode.. It was really good.. I've downloaded cross-platform GUI programming with pyqt book.. But it's not an ideal book to start with for the … | |
Ok, uhh... I need help. My loop to keep the program running or to quit isn't working right. Can somebody help me figure it out? I tried a couple of methods, and they didn't work. Do anybody have any idea? By the way, this is for a blood drive program … | |
Hello together, sorry for my bad english. I'm complete new to python and its very difficult for me, so i hope that you can help me. i have got a csv in which there are names and telephone numbers. Now i have to do an program that shows me the … | |
In the following program, I have three different comments each after a line of code. Please read those comments to answer my questions. [CODE] # Property Critter # Demonstrates get and set methods and properties class Critter(object): """A virtual pet""" def __init__(self, name): print "A new critter has been born!" … | |
I have some cnf files, which are txt files that are in a specific format for conjunctive normal form formulas. I want to take this file, which looks something like this: c The random seed used to shuffle this instance was seed=1755086696 p cnf 1200 4919 -35 491 -1180 0 … | |
System: Xubuntu, Karmic 9.10 Compiler: gcc Python: python2.6 IDE: CODE::BLOCKS Trying the following example: #include "Python.h" void initxyzzy(void); /* Forward */ int main(int argc, char **argv) { /* Pass argv[0] to the Python interpreter */ Py_SetProgramName(argv[0]); /* Initialize the Python interpreter. Required. */ Py_Initialize(); /* Add a static module */ … | |
[COLOR="Red"]Note two things: First off, I don't guarantee that it works well. Writing to files, if done wrong can always break things. Be careful. I mostly participate in this forum (the Python part) for fun, and my code is written like that. Second: this script is about copying things. I … | |
Extract Blocks of Info from Log File New learner..this would be my first try at writing in Python that I can actually put to use: Have log file content that looks like [URL="http://i.imgur.com/RcU3J.jpg"]this[/URL] Basically - I only want to keep "slots" with the indicator "[COLOR="Red"]/* mysql */[/COLOR]" - the blocks … | |
Hi, my professor is asking a project. Overview: Get x number of students for a simple survey. Make a data analysis, including [1] name [2] gender [3] ID [4] Question 1 and data analysis - probability - % - distribution In this project, each student is an "object" I am … | |
Thanks for your input vegaseat. I have posted the code that is giving me the problem in the two scripts and I hope you can comment further. Thanks in advance - Elvedon. [CODE]#The script displayed below is only part of the larger original script.# #filename = 'firstScript.py' #!/usr/bin/python from Tkinter … | |
Hi, I need to login to a site, make some changes and then there is an apply button which i need to click to save the changes. The HTML code is as below for the buttons [ICODE]<input type="button" onclick="clickApply()" alt="Apply" value="Apply " class="button" name="applybutton" id="postApply"/>[/ICODE] I am able to login … | |
Hello, I'm fairly new to programming, and am working on a project for a programming class. I've run into a problem, and need some help... I'm writing a hangman game and I'm having trouble getting the guessed letter to replace the correct hidden letter. Say the word is DICTIONARY, if … | |
In the following program, the second line in main print [COLOR="Red"]"Printing a Card object:"[/COLOR], is not showing up when I run the program. Could someone please tell me what's going on? Thanks. [CODE]# Playing Cards # Demonstrates combining objects class Card(object): """ A playing card. """ RANKS = ["A", "2", … | |
I am using SWIG to extend Python to C++. Understand that there is a different forum for SWIG users but I am still waiting for a response on that list. But the questions I have consists of basic Python C API releated. I hope this list will be able to … | |
[CODE]import re, os ...from os.path import join as pjoin, isdir ...targetdir = raw_input('c:\volatility-1.3_Beta>c:\python26\) ...os.chdir(targetdir) ...if targetdir = raw_input ...then exec ('python.exe volatility pslist -f c:\python26\nick.img')[/CODE] ************************** Can you help please... Trying to run this program to execute the currently runing processes on the \nick.img... that I capture... program not working... … | |
Can someone help please! I need to search for a different set of strings like: 'fummy' or 'users' or 'logon' from a directory like this: C:\mycase\Nic..\ A Text document is stored in there LIKE: 544, Text Document, 45, 588 KB Can some help to write a script or python program … | |
Ok. So. Who doesn't know how to convert on paper or in their head decimal numbers ==» binary number, or vise-versa? Well. I've successfully programmed a conversion calculator for those who just never took the time to learn, for those who don't care to learn, and for those who've got … | |
I've been trying to figure out how to capitalize all the sentences in a string. In the string [CODE]a = "this is the test string! will it work? let's find out. it should work! or should it? oh yes. indeed." [/CODE] I want all the characters after [I]". " "! … | |
Here we apply the module difflib to compare two texts line by line and show the lines of the first text that are different from the second text. | |
[CODE]element = {'H': 1, 'N': 6, 'F': 7, 'Cl': 7} i = input("Enter: ") dots = '*' totalDots = (dots * i)[/CODE] Enter: H Traceback (most recent call last): File "D:/Python26/lewisdot.py", line 4, in <module> i = input("Enter: ") File "<string>", line 1, in <module> NameError: name 'H' is not … | |
Hi, i am new to python world my problem is that i am getting a output file from a software which is very messy first i just want to delete first 3 rows and the columns F onwards from the excel file and that i just want to change the … | |
hi everybody!!! I will really appreciate if somebody could help me.... we are working with c and python and the same time and it gets confusing sometimes... I need to write a program in python tha will receive a string and it will print only the number in the string … | |
Hi how to get wat all buttons are present in GUI window using python here i want to read all the buttons present in a window . | |
I need to analyze a list of five cards as a poker hand. After printing the cards, the program needs to categorize accordingly. Royal Flush: 10, Jack, Queen, King, Ace all of the same suit. Straight Flush: Five ranks in a row, all of the same suit Four of a … | |
Hey guys, im verymuch stuck on my assignments and its due today. i was wondering if someone could help write the program. Ive attached a zip file containing the detail of the assignments, there are three in total. I really would appreciate any help. thnx naz | |
I require a program that will remove all trailing whitespace (any spaces that occur at the end of a line) from a text file. It should do something like: Space Stripper Enter the name of the file to be stripped: news.txt Any help would be gladly appreciated. I'm also seeking … | |
Hello, I'm having a slight problem with my code. The task is to create an indexing program, similar to the ones the google uses. The problem i'm having is that we have to remove the common ending from the words left after the removal of stop_words(which is a list variable … | |
hey everyone, i am writting an app with tkinter, well ive tried quite alot of different ways but i couldnt find the solution for my problem. So, in that window there is time and i need it to constantly change, like every second. Any ideas? Thanks Dan08 | |
Hi, I'm having some issues with a maze solver that I'm coding for an assignment. Here's what I have so far: [CODE] def main(): maze = open(raw_input("Please enter the filename of the maze:"),'r') x=0 y=0 with maze as maze_file: maze = [list(line.strip()) for line in maze_file] for i in maze: … | |
Okay, well I'm having trouble getting a variable from one place to the other. I have two scripts: for now, let's call them MainScript.py and ChildScript.py. [code=python]#!/usr/bin/python # MainScript.py import ChildScript from Tkinter import * class GetVariable: def __init__(self): master = Tk() master.withdraw() ChildScript.VariableDialog(master) # From right here, I would … | |
I need help with an online tutorial (this is not homework) [url]http://www.upriss.org.uk/python/session3.html[/url] It is something very simple, but I am a beginner so I don't understand yet. Write a script that asks someone to input their first name, last name and phone number. If the user does not type at … | |
Hi, I am new to python but learned somewhat about lists, tuples, dictionaries, db and gui (just introductory stuffs), and am trying to write a program that will alllow users to input some key words to search in a report. if key words are present in the report then the … | |
This is some code I wrote for a music program... Any way on making it neater/more pythonic? [CODE] from Tkinter import * import pygame playlist=[] pygame.init() pygame.mixer.init() camera=pygame.mixer.Sound("E:\\Peter\\Python_stuff\\data\\Music\\camera1.wav") one=pygame.mixer.Sound("E:\\Peter\\Python_stuff\\data\\Music\\one.wav") wrong=pygame.mixer.Sound("E:\\Peter\\Python_stuff\\data\\Music\\wrong.wav") root=Tk() root.title("DJ Pro") def sound_play(event=None): playlist.append(wrong) wrong.play() def sound_play1(event=None): playlist.append(one) one.play() def sound_play2(event=None): playlist.append(camera) camera.play() def play_all(event=None): for ii in … | |
i am trying to make a password system that will run another one of my programs when answered correctly. not sure how to call my main program in the password prog function. i have played w this over and over, and browsed the library and i am officially stuck. :) … | |
The American Heart Association (AHA) suggests that at most 30% of the calories in our diet come from fat. Although food labels give the number of calories and the amount of fat per serving, they often do not give the percentage of calories from fat. This percentage can be calculated … ![]() | |
Can someone help please! I need to search for a different set of strings like: 'fummy' or 'users' or 'logon' from a directory like this: C:\mycase\Nic..\ A Text document is stored in there LIKE: 544, Text Document, 45, 588 KB Can some help to write a script or python program … | |
I cant get text working in my programs if I double click the icons in windows but it does work in the WinEditor. Why doesnt it work and what could I do to get text working wherever? | |
First let me say I know absolutely nothing about Python. All I know for sure is that I own the PC game Vampire Bloodlines and I am getting a runtime error. I have researched online and have read that if you have an older version of Python the game will … | |
Hello I an new to python I want to write a function which save the contents to disk I am using GTK also to design . On clicking the save menu item the output should be able to saved at any desired location {on_save_activate()}. Please help me to write the … | |
Hello fellow python programmers. I had an idea the other night when watching a video on the creation of the Tasque application. Developers at novel are given a week called "Hack week" were they have no management and are allowed to code anything they like. Well two of the developers … | |
I am making a game using pygame and livewires. I am having trouble with the scoreboard- it updates appropriately but does not delete the old scoreboard, thus creating a blob of numbers: [CODE]class Ship(games.Sprite): """Ship, represents the player""" image = games.load_image("ship.bmp") DELAY = 25 def __init__(self, x, y): super(Ship, self).__init__(image … | |
hello, I've wrote this calculator [code=python] from __future__ import division class num: x = input ("Input first number:\n") numb = num() class wtd:#wtd= what to do command = raw_input("What do you want to do?\nadd +\nsubstract -\ndivide /\nmultiply *\n") cmd1 = wtd() bull1 = cmd1.command while cmd1.command != "+" and cmd1.command … | |
In the following program, why is [COLOR="red"]"Ac"[/COLOR] the first thing that the program outputs? In main, [COLOR="red"]print "Printing a Card Object"[/COLOR] is the first think I see that should print anything. Is it the [COLOR="red"]__str__[/COLOR] method using the rank & suit attributes from the [COLOR="red"]__init__[/COLOR] constructor? [CODE]# Playing Cards # … | |
this is my code: [CODE]import os,sys import random import webbrowser import time import subprocess as sp cls=os.system("cls") title=os.system('title Hit any key to start searhing!') while True: cls print "" title raw_input() getRandEntry() def getRandEntry(): theFile = open("wordlist.txt","r") wordList = theFile.readlines() theRandoms = [] theRandoms.append(random.choice(wordList)) * 4 startLink(theRandoms) return theRandoms def … | |
Hi, I am still very new to python and programming so could anyone help me on how to input lines from a user, one line at a time until they type "." on a separate line. I also wanted to count how many lines they entered. What I tried was … ![]() | |
hey folks, i'm trying myself on a csv based adressbook but I get the following error: [CODE] Traceback (most recent call last): File "C:\Dokumente und Einstellungen\Mo\Desktop\adressbook.py", line 11, in <module> writer.writerows(data) File "C:\Python26\lib\csv.py", line 149, in writerows rows.append(self._dict_to_list(rowdict)) File "C:\Python26\lib\csv.py", line 140, in _dict_to_list ", ".join(wrong_fields)) ValueError: dict contains fields … | |
I'm having difficulties parsing filepaths sent as arguments: If I type: [code]os.path.normpath('D:\Data2\090925')[/code] I get [code]'D:\\Data2\x0090925'[/code] 0bviously the \0 in the folder name is upsetting the formatting. I can correct it with the following: [code]os.path.normpath(r'D:\Data2\090925')[/code] which gives [code]'D:\\Data2\\090925'[/code] My problem is, how do I achieve the same result with sys.argv, namely: … |
The End.