15,190 Topics

Member Avatar for
Member Avatar for Taruna_1

Hi, I want to replace all the character in my string with 'aaaa' as many number of times as there are occurence of the character. For eg. if my string is "cat", output should be "aaa" and if its "hello" output should be "aaaaa". As of now, I am using …

Member Avatar for vegaseat
0
321
Member Avatar for np complete

Hi, I'm new to python so I'm asking a noob question. I'm given a large string from which I have to take all the digits and check if its prime or not. Then I have to take the first 25 chars of the string and append the prime digits to …

Member Avatar for Gribouillis
0
234
Member Avatar for Taruna_1

Hi, I have a list which contains strings in each value. I want the word count of each string and then I will have to find out the string with minimum word count and max. word count in that list. Help is much appreciated.

Member Avatar for Taruna_1
0
781
Member Avatar for farmwife

Okay, so cryptography is insanely well developed and I'm not doing anything new here, but I still thought I'd monkey around with a cryptography project. Here's what I want it to do: 1) generate an encryption and decryption key that is randomly between 20 and 40 digits long and contains …

0
102
Member Avatar for farmwife

Suppose you have this file named func.py: def func(x): y = raw_input(x) return y func(z) And then you have this calling code: z = raw_input('Type a request for input and hit enter: ') omega = execfile('func.py') print(omega) Why does the output always end up being "None?"

Member Avatar for farmwife
0
1K
Member Avatar for TrustyTony

Here is exercise in error handling, while looping and for looping with itertools.chain. It is also exercise of functions not letting user to go without giving proper input. I call them to myself 'jail functions'. Here you could add as an exercise breaking out of loop and continuing until user …

Member Avatar for farmwife
0
1K
Member Avatar for Tcll

Just to note, this thread may never be marked solved until my main project evolves. anyways... To put it simply, this language is a common-interface language meant for conversion between all languages. This means that this language has to support all features between all languages in the most simplest of …

Member Avatar for Tcll
0
304
Member Avatar for james.lu.75491856

class stdout(object): def __init__(self,realout,prefix): self.file = realout self.at_start_of_line = True self.prefix=prefix def write(self, text): if len(text): if self.at_start_of_line: text = self.prefix + text self.file.write(text) self.at_start_of_line = (text[-1] == '\n') sys.stdout=stdout(sys.stdout,"OUT ["+f+"]> ") File "C:\Users\James\Desktop\run.py", line 13, in write self.file.write(text) File "C:\Users\James\Desktop\run.py", line 10, in write if self.at_start_of_line: AttributeError: 'stdout' object …

Member Avatar for james.lu.75491856
0
163
Member Avatar for giancan

Dear friends, I have a set of values as follows (filename is string; values are floating; notimportant... is self-explaining): filenameA, value1_1, value2_1, value3, value4, notimportant filenameA, value1_2, value2_2, value3, value4, notimportant filenameA, value1_3, value2_3, value3, value4, notimportant filenameA, value1_5, value2_5, value3, value4, notimportant filenameA, value1_7, value2_7, value3, value4, notimportant ... …

Member Avatar for Gribouillis
0
229
Member Avatar for james.lu.75491856

def GenContent(address,what): return urllib.urlopen("http://www.yelp.com/search?find_desc="+what+"&#find_loc="+address).read() I am using python to do this. It works prefectly in my browser.

Member Avatar for chriswelborn
0
312
Member Avatar for raashil.gilchrist

I'm creating a shooting game and I don't want to allow unlimited bullets to be shot on the screen, so how can I limit the amount of bullets fired. heres the code # Sample Python/Pygame Programs # Simpson College Computer Science # http://programarcadegames.com/ # http://simpson.edu/computer-science/ import pygame, sys, random from …

Member Avatar for raashil.gilchrist
0
672
Member Avatar for Hamza_4

I have a directory with hundreds of CSV files in it. Many of the files have synonyms for words that I no longer want. I want to replace all of the synonyms with approved words. For example some CSVs have synonyms like `vial` `jug` `canteen` `urn` etc and I want …

Member Avatar for vegaseat
0
244
Member Avatar for martin.schmidt.9465

I made this program this morning, the problem is that when I go to run it it says: > Traceback (most recent call last): > File "C:/Python33/Test random number creator.py", line 4, in <module> > print (x)('x')(y) > TypeError: 'NoneType' object is not callable > ` Here is the program: …

Member Avatar for martin.schmidt.9465
0
20K
Member Avatar for Ene Uran

More or less a templet database that allows you to load, save, add, list, search, edit and delete data items. I used movies as an example, but you can easily change that to make a database of many other things.

Member Avatar for james.lu.75491856
1
991
Member Avatar for Reethu_1

Duplicate occurance of the same value has to be removed. If the (linked)list traversed from head contains sequence 3,2,8,8,8,5,2,3 after calling last = Node(3) head = Node(2, last) head = Node(5, head) head = Node(8, head) head = Node(8, head) head = Node(8, head) head = Node(2, head) head = …

Member Avatar for TrustyTony
0
808
Member Avatar for martin.schmidt.9465

I am very new to python and I just created a program: a = input('10x2= ') if a==20: print ('Correct!') if a!=20: print ('WRONG! Try again') a = input('10x2= ') if a==20: print ('Correct!') if a!=20: print ('WRONG! Try again') a = input('10x2= ') if a==20: print ('Correct!') if a!=20: …

Member Avatar for martin.schmidt.9465
0
160
Member Avatar for lionaneesh

[B][I][U]Introduction [/U][/I][/B] [COLOR="Red"]Hey everybody welcome to a tutorials on classes in PYTHON. The purpose I made this tutorial for is that when I was learning classes in python I dint found any good tutorials on Classes. Maybe I was wrong. But here's my tutorial.[/COLOR] [B][I][U]Layout[/U][/I][/B] In this tutorial i'll be …

Member Avatar for mail2sanjay
1
866
Member Avatar for sujan.dasmahapa

I am trying to enter user name and password from command line. user name is 'example@gmail.com' and password is 'Example$319'.....When I am printing this values I can see the password is wrong. I am typing Example$319 but it is printing 'Example19'. $ and 3 are discarded.....Please help me what is …

Member Avatar for almostbob
0
4K
Member Avatar for 3e0jUn

Is there any way I can execute a block of code in a loop, like so: [ some code goes here ] Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.: [the user can create another loop[]] I am creating a parser for a language …

Member Avatar for 3e0jUn
0
139
Member Avatar for mudabbir.siddiquii

Hello guys, i hope everyone is doing good. I'm willing to learn Network Security and after reading a number of blogs i think python is one of the best language for that (correct me if i'm wrong). I'm not an experinced programmer so i need some help regarding what should …

Member Avatar for Rahul47
0
173
Member Avatar for james.lu.75491856

def mu_cache(func,maxsize=128): "Most Used Cache decorator" cname = "__"+func.__name__+"_Cache" rname = "__"+func.__name__+"_Rankings" exec("global "+cname) exec(cname+" = {}") #here exec("global "+rname) exec(rname+" = {}") def wrap(*args,**kwargs): cache = eval(cname) rankings = eval(rname) try: res = cache[(args,kwargs)] except: res = func(*args,**kwargs) cache[(args,kwargs)] = res else: try: res = rname[(args,kwargs)] except: res=0 rname[(args,kwargs)] …

Member Avatar for sepp2k
0
346
Member Avatar for Jake_1

Hi, I was wondering how I could create a MUD (Multi-User-Dungeon) game using Python. It would be a dream come true if I could make one on my own so I was wondering if there is any reading material (pdf) that could teach me. What functions and commands would I …

Member Avatar for james.lu.75491856
0
460
Member Avatar for The_2
Member Avatar for Aakeem

I was wondering if there was a way to use the values in a list one would create. Such as secrete_door = [1,2,3,4] print "Choose the right door and you may proceed." print "Guess a door 1 through 4." # I would like to pull a number from the list …

Member Avatar for ddanbe
0
154
Member Avatar for ddanbe

After reading the intresting articles of vegaseat, I finally decided to get my toes wet. So I installed Pyton 3.3.2 amd the plugin for Visual Studio 2010. The best learning is of course practice, so I started coding right away. Here is my first try: import sys print('Hello World') print('I …

Member Avatar for vegaseat
0
269
Member Avatar for HiHe

Can anyone give this a try? '''print_error_python33.py there are times when a print() trailing newline disappears with Python 3.3.0 this does not happen with Python 3.2.3 or Python 2.7.3 ''' size = 180000 print("creating long string of %d sevens" % size) # create a long string of digits s2 = …

Member Avatar for vegaseat
0
335
Member Avatar for dreking6

newbie question, but please i need help i just started learning gui programming on python, been getting this error on a code am writing concerning uising the get() method to read an integer from my entry box from Tkinter import * root=Tk() var=StringVar() label=Label(root, textvariable=var, relief=RAISED) var.set("converter") label.pack() L1=Label(text="x:") L1.pack(side= …

Member Avatar for dreking6
0
2K
Member Avatar for paramesh23

Which Is simple To learn Php with mysql or python with mysql ?? php or python with some other database...??

Member Avatar for aVar++
0
115
Member Avatar for Trap910

I am new into the computer Science..I just completed reading and understing the C programming language..I think am quite decent in it..Now I want to start studying a new programming language this semester, before I start, I want to get some advice from the experts, should I choose Java or …

Member Avatar for vegaseat
0
282
Member Avatar for np complete

I want to start a program and pass arguments used by that program. How to do this using os.spawnl ?

Member Avatar for Gribouillis
0
224

The End.