75 Posted Topics

Member Avatar for webstart
Member Avatar for windiggy

and another way as PyTony mentioned: color = raw_input ( "Input a color component character: ") if color.strip().lower() in "rgb": print "You have input a color component" else: print "You have not input a color component"

Member Avatar for woooee
0
361
Member Avatar for vlady

a simple table: subjects = [ 'maths' , 'fyzics' , 'history' ] header = "<h4>Study Subjects</h4><table>" footer = "</table>" def write(): f = open( 'vysvedcenie_test.html' , 'w' ) f.write(header) for subject in subjects: body = "<tr><td>%s</td></tr>"%subject f.write(body) f.write(footer) f.close()

Member Avatar for woooee
0
192
Member Avatar for crazy99

@crazy99: have you ever tried to read documentation or any tutorials? just vizit the links woooee gave you, then review the answers in this thread, and you'll find out how to solve your problem.

Member Avatar for crazy99
0
342
Member Avatar for M.S.

Hi I found this script from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189858 it uses getopt module for managing cmd arguments, but I need it to work on mobile phones. I want to make a Mobile app using this script but I cant figure out how to change the comand Args to simple raw_inputs. can somebody …

Member Avatar for M.S.
0
412
Member Avatar for SlzzyDzzy

for printing all even numbers bellow 412 you can do this: ~~~for i in range(0,412): if i%2==0: print i~~~ and for a specific list of numbers: ~~~for num in num_list: if (num<412) and (num%2==0): print num~~~

Member Avatar for M.S.
0
187
Member Avatar for woooee

these tricks might work for a Desktop, but not for a mobile user. I use my phone for coding, making threads and posting in the forum and unfortunately these new changes in daniweb, makes it a hard job. there is no ctrl+a then indent or any other shortcuts on my …

Member Avatar for TrustyTony
0
258
Member Avatar for pakiali007

[CODE]def middle(name): names = name.split(' ') if not (len(names) <=2): middle_names = names[1:-1] return ' '.join(middle_names) else: return 'There is no middle name in %s'%name print middle("Michael smith Jordan Jones") print middle("Michael Jordan Jones") print middle("Michael Jordan") print middle(raw_input("Enter a name")) [/CODE] Note: it is assumed that the "name" entered …

Member Avatar for TrustyTony
0
237
Member Avatar for minimee120

here is what comes to my mind, but you need to add some codes to take the inputs and check their correctness: [code]import random def distance(minlen, maxlen, steps): total_distance = 0 step_count = 0 while step_count < steps: step_length = random.randint(minlen, maxlen) total_distance += step_length step_count += 1 return total_distance …

Member Avatar for M.S.
0
158
Member Avatar for hokeysmoke

for writing into file, I suggest codecs: [CODE=python]import codecs out_file = codecs.open("some_file.txt", 'w', 'utf8') out_file.write('español') [/CODE]

Member Avatar for hokeysmoke
0
3K
Member Avatar for M.S.

I tried many times but no luck. I want to parse a text file with a vcard format (from my phone contacts). the text file looks like this: BEGIN:VCARD VERSION:2.1 REV:20110913T095232Z UID:aac119d5fe3bc9dc-00e17913379d6cc8-3 N;X-EPOCCNTMODELLABEL1=First name:;[B]Maj[/B];;; TEL;VOICE:[B]09120000000[/B] X-CLASS:private END:VCARD BEGIN:VCARD VERSION:2.1 REV:20110228T083215Z UID:aac119d5fe3bc9dc-00e17b0693898c98-4 N;X-EPOCCNTMODELLABEL1=First name:;[B]Ali jahan[/B];;; TEL;VOICE:[B]09120000001[/B] X-CLASS:private END:VCARD BEGIN:VCARD VERSION:2.1 REV:20110228T083510Z …

Member Avatar for snippsat
0
2K
Member Avatar for pwolf
Member Avatar for TrustyTony
0
2K
Member Avatar for BnayaArbel

you can write scripts or develop apps in python for android; but they need the sl4a and py4a to run. it is necessary to have them installed in order to run python apps.

Member Avatar for Tech B
0
138
Member Avatar for Cap.Alvez

[QUOTE=;][/QUOTE] there are some ports of python for cellphones: PyS60 for Symbian phones(you can find many many apps written in python for this OS) Python for MeeGo. python for Maemo Python for Android a.k.a Py4A based on SL4A project

Member Avatar for M.S.
0
196
Member Avatar for Flames91

in python 2.x: [CODE]test = [] for i in raw_input("Enter numbers separated by a coma(,):").split(','): test.append(int(i)) neg_sum(test)[/CODE] EDIT: sorry Moders, while I was posting, it got solved.

Member Avatar for arson09
0
777
Member Avatar for mjohnson

it could be much shorter: [CODE]#User and Pass files: userN = open('username.txt', 'r').read() pasN = open('password.txt', 'r').read() # First make your Functions and Then Use Them the way you want: def username(): pin = raw_input ("Please insert your username: ") while True: if pin == userN: print 'You Did It!' …

Member Avatar for mjohnson
0
1K
Member Avatar for The_Tiger

My Beginners' Solution: [CODE]def main(): print "This program calculates a numeric value for a name.\n" first, last = raw_input("Enter your first and last name (with a space): ").lower().split() print "\n","-"*10 totalFirst = 0 totalLast = 0 for ch in first: totalFirst += ord(ch)-96 print ch,"=",ord(ch)-96 for ch in last: totalLast …

Member Avatar for Tech B
0
123
Member Avatar for Tourbillion

[QUOTE=;][/QUOTE] A hint: (Im a newbie too:D) [CODE]message = raw_input('Enter Message:') newMessage = '' for char in message: crypted = ord(char) newMessage += str(crypted) outfile = open('CryptedMessage.txt', 'w') outfile.write(newMessage) outfile.close()[/CODE]

Member Avatar for TrustyTony
0
265
Member Avatar for bigredaltoid

for the other part of your question: [CODE=python]word = raw_input('word: ') word.split() print '*'.join(word)+'*' #>>> H*E*L*L*O*[/CODE]

Member Avatar for TrustyTony
0
405
Member Avatar for M.S.

Hi All How can I select some random names from a list, so that in next time, those previously selected names become omitted from the list? for example, say we have 100 names in test.txt file, and we want to select 3 names randomly. then by recalling the selection function, …

Member Avatar for M.S.
0
6K
Member Avatar for felix001

maybe something like this: [CODE=python]porttype = "Gi" print "sh int counters errors | i %s.*/1 " % porttype >>> sh int counters errors | i Gi.*/1[/CODE]

Member Avatar for felix001
0
571
Member Avatar for TrustyTony

Is "d" here stands for "digit"? this bellow code does the same but instead of 0's it prints empty spaces" [code=python]print('%0*s' % (3, 7))[/code] what about "s" here? does it mean "string"?

Member Avatar for Purkinje
1
195
Member Avatar for M.S.

Hi All When trying to open a URL with bellow code, it Gives "TypeError: not all arguments converted during string formatting" [CODE=python]import urllib City="%D9%85%D9%87%D8%B1%D8%A7%D9%86" Province="%D8%A7%DB%8C%D9%84%D8%A7%D9%85" myurl = 'http://www.owghat.com/owghat.png.aspx?Province='+'%s'+'&City='+'%s'%(Province, City) #the real address is:http://www.owghat.com/owghat.png.aspx?Province=%D8%A7%DB%8C%D9%84%D8%A7%D9%85&City=%D9%85%D9%87%D8%B1%D8%A7%D9%86 a="e:\\img.png" urllib.urlretrieve(myurl,a)[/CODE] So, what I'm doing wrong? AND Another question: How to encode a utf-8 string(example: مهران) …

Member Avatar for M.S.
0
165
Member Avatar for M.S.

Hi All Please some one Help me find out why this code doesn't work: [code=python]codes=['zlib', 'zip', 'base64', 'hex', 'utf-8'] def encoder(str, i): return str.encode(codes[i]) def decoder(str, i): return str.decode(codes[i]) en = encoder('Some string here', 2) print en[/code]

Member Avatar for M.S.
0
109
Member Avatar for M.S.

Hello All This is my first post in this forum, despite my long visiting hours as a guest:D I don't have any background in programming and I'm a newbie in python too. But Learning python for S60(Python distro for Symbian Phones. anyway, I have a problem with printing from two …

Member Avatar for M.S.
0
538

The End.