15,179 Topics
| |
I have dictionary with single element lists. [CODE]dictionary={'a':['A'], 'b':['B'], 'c':['C']} [/CODE] How can i change it to [CODE]{'a':'A', 'b':'B','c':'C'}[/CODE] | |
Hi I have a question about a problem I'm having with raw_input function in python. I'm writing a CL program that requires a comment to be entered by the user, however problems arise when someone makes a mistake entering said comment. [CODE=python]comment = raw_input(Enter comment: )[/CODE] User Input: Archie^?ve testing, … | |
I dont know what goes wrong in this piece of code?!! I keep getting the following error. File "<stdin>", line 11 t1.append(list[temp]) ^ SyntaxError: invalid syntax [CODE]tl = [] for inlist in token_list: temp=[] for token in inlist: temp.append((zlib.adler32(token,65521)) tl.append(temp)[/CODE] | |
I have a class with a button, it runs the command automatically when the gui is constructed (which i dont want it to do) but then doesnt work again after. What am I doing wrong? Builtin commands such as endcommand work as they should. relevant excerpts (ignore the indent problem … | |
Hello, I have been working on this code but I can't seem to make it work. I want to implement function index() that takes as input the name of a text file (as a string) and a list of words. For every word in the list, the function will print … | |
Okay, I started learning Python last weekend on Saturday with some tutorials and a book. With this being my first programming language my program won't amaze you :P The program I made is a calculator for working out how much turf a person would need given the length and the … | |
Is it possible to sort a list of numbers from largest to smallest? Like if I had a list of numbers in variable a | |
im wanting to sort files by size and pick the top 20 i have managed this with the glob.glob statement but it does not work quickly and does not pick up if a file is modified/ added while the code is running. i have worked out how to do this … | |
Hi I am in a web programming class and have been struggling greatly with this assignment. I am not very familiar with Functions and so forth but I have been truthfully working on this for a few days now. I am at the point where I am stuck. I would … | |
Takes an XML, XHTML, HTML, Javascript or CSS file and creates a pretty printing version. | |
I am new in Python. May any one tell me how to validate XML file in python from DTD and Schema document.... | |
[CODE]f = open("summatest.01.sis", "rt") n = (f.readline()) jada_elemendid = f.readline().strip().split(' ') otstav_summa = f.readline().strip() f.close() # Valjund vfal = file("sum.val", "w") lmargid = [] def otsi(k): if (k < n): print n k = k + 1 lmargid.append("+") if otsi(k): return True lmargid.append("-") print lmargid else: z = jada_elemendid[0] for … | |
In python it will give a decimal like 52.2 and I was wondering if there was a way to make it round all decimals up to the next number like 53. | |
If I have a list and I already have split the line in the file. I also have figured out the code to average the numbers in the list now I have want to figure out a way to somehow take the average from the list of numbers and give … | |
Hello fellows... Is there something like static function variables in python? I know there are static attributes of a class, but what if i want to use a static variable inside a function? somthing like this (stupid) code in c++ for example: [code]int static_num() { static int x = 0; … | |
To maximize the value of the knapsack The output should like this >>>Bags=[mkBag('cooper',30,120),mkBag('silver',20,100),mkBag('gold',10,60)] >>>knapsack(Bags,50) [('gold',1.0),('silver',1.0),mkBag('copper',0.666666666)] [CODE] class Bag(): __slots__ = ('name', 'weight','value', 'ratio') def mkBag(name,weight,value): bag=Bag() bag.name = name bag.weight = weight bag.value = value bag.ratio=value//weight return bag def printbag(bags): print("Name:", bag.name, "Weight:",bag,weight,"Value:", bag.value) def knapsack(bags,maxweight): bags=sorted(bags, key=lambda mkBag: mkBag.ratio) … | |
Hello, We are trying to use Django with couchdb, is this a good idea??? It is going to be a health software, so is it better to use couchdb. Also we are going to use wtforms. Will this make a good combination for a complete software. Any more suggestions will … | |
Hello, I'm a new python user and I'm trying to create a python program that will run on a targate and communicate with the terminal. The main idea is to run several commend and short programs and analyze the results. for example running those 2 commands: cd /home/user/folder ls | … | |
below is how an snmp get is issued using pysnmp errorIndication,errorStatus,errorIndex,varBinds = cmdgen.CommandGenerator().getCmd( cmdgen.CommunityData('xxxx', 'xxxx', 1), cmdgen.UdpTransportTarget(('192.168.5.157', 161)), (1,3,6,1,4,1,18489,1,2,1,4,5,[B]1[/B],0)) In the OID part, the integer in bold keeps changing from 1 to 38. I need to put the above in a loop, instead of issuing 38 seperate gets. how can … | |
The map() function applies a function to every member of a list. Here a list of numbers 32 to 255 is changed to a list of the corresponding ASCII characters. Then map() is used in a more complex application to combine the two lists to form a dictionary containing number:character … | |
I have a list of lists [CODE]x=[['a', 'b', 'c', 'd'], ['e', 'f'], ['g', 'h']][/CODE] I need the following output. [CODE]a-b a-c a-d b-c b-d c-d e-f g-h[/CODE] How can i do this? Can a regular expression be used here?? | |
haiii Do anyone know how to convert array like this ['26','18','20'] into [26 18 20] because i have to plot graph for these value, ['26','18','20] array is not allow me to do that ,i got ['26','18','20'] from database table with data type varchar....problem is i shouldnot change the datatype .... … | |
[B]hi... I have a value, value=4501-E001 I am concerned about only the value before hyphen i.e., 4501 I need to check whether various values begin with 4501, followed by something, n am not concerned about "something" that follows. How can this splitting be done in python?[/B] | |
I am making a program for my CS class. Is there a way, in python, to set more than one value to a variable? Am I thinking about this in the wrong way? I need to make a program that asks a bank account holder for their username. If that … | |
hello guys suppose if want to open a file in Notepad application, it have short cut key(shift+ctrl+o). So to open a file, using the short cut key, i have to write python script. could please give some example. Regards kumar | |
hello guys, I am writing automated python script. How can i propagate the result of each script in XL sheet, whether the script is passed or failed. could you please help me For example , my first script is to verify 'open an existing project' and second script to verify … | |
hello guys, I have written a script to open notepad and added the text in script, after that i want to save the file in text format. from pywinauto import application from pywinauto import application app=application.Application() app.start_('Notepad.exe') app.Notepad.edit.TypeKeys('hello') app.Notepad.MenuSelect("File->Open") app.Notepad.MenuSelect("File->Save")/*saveas dialog box opened and waiting for the filename*/ Please guide … | |
hiiii all, Can anyone please help me regarding this .... i have table with 2 cloumns in a database "details" Name Age john 26 Mary 18 Nancy 20 i want to get only the Age in an array. I tired in this way: db=MySQLdb.connect(user="root",passwd="my",db="mydb") cursor=db.cursor()# prepare a cursor object using … | |
Hi, I want to start preparing for an IT Olympiad for next year for a chance to get a full bursary for college. We can choose between Java, Python, C and C++. Of the lot I'm most comfortable with Python seeing that I at least have a bit of experience … | |
Hello, new coder here :-) I've been working on one of my first scripts, an SMTP script for sending mail with Gmail. It works and all, but I wan't to have an "if" the login to the server failed, it would print and message saying so and return to the … |
The End.