I have code that when executed will give me a long list output, which is fine, but how can I get it to print without the parenthesis and commas? example: answer =('7', 'Q', '5', 'H', '9', '4', '3', '8', 'L') but I'd like it to print like this: 7Q5H9438L I tried ans=answer.split(",") to remove commas but it didn't work.

Member Avatar
Member Avatar
+0 forum 7

I'm trying to use this code for a fibonocci sequence where I'm setting the starting numbers as b= and c=. What I'd like to do though is have it stop after so many numbers are added together, in this case it would be 53rd (a=53). I've tried a 'for i in range(53):'loop but that doesn't work for this. The a,b,c numbers can be randomly choosen, which I have working, but for this snippet I'm setting them as static. Suggestions? a = 53 b = 7 c = 18 k, l = b, c while l < 9999999999999999: xa = l …

Member Avatar
Member Avatar
+0 forum 5

Hi, If I have a sentence like this: "I now have a total of % yellow bananas!" but I need it to change the number 2 to a 3, print, then a 4, print, etc until it reaches a set number like 10, how can I go about that? sentence = "I now have a total of % yellow bananas!" for i in range(2,11): print sentence %i but that gets me an error: ValueError: unsupported format character 'y' (0x79) at index 9 When I try it with a different sentence: sentence = " I have % dogs!" for i in …

Member Avatar
Member Avatar
+0 forum 4

Hi, I'm trying to run code that asks a yes or no question. If a yes or no isn't entered, then the question will continue to re-ask say every 3 seconds until a yes or no is entered. Here's the basics of it: [code] while True: response = raw_input(" Are you ready? ") if response.lower() == "yes": print ("Then lets get started!") break elif response.lower()=="no": print ("Please try again later....") break else: print ("Please enter a 'yes' or 'no' response!") [/code] With that, I can add another while True: after the last 'else' statement but that's not exactly what I'm …

Member Avatar
Member Avatar
+0 forum 8

I'm having trouble getting my python scripts to insert into a mysql database. I'm able to do other commands successfully such as adding or dropping tables, selecting items from tables but inserting into tables isn't working. I can manually insert but the script won't do it. I have an entry field for a last name and am using .get() to grab the data. If I enter the name 'Jones' into the field and submit it, I get this error: OperationalError: (1054, "Unknown column 'Jones' in 'field list'") If I move the quotes around I won't get an error message but …

Member Avatar
Member Avatar
+0 forum 2

I've been working on a project lately that is written in python and I want to incorporate mysql into it. The python code is basically a sales report writing system in which every sales report will have it's own number such as 10-0001, 10-0002 and will contain customer information like first & last names, addresses, phone numbers, etc. There is also a page, if needed, for items such as televisions, brand names of items, color of items, serial numbers of items, values of items, etc, and there will also be a narrative page where several paragraphs of info can be …

Member Avatar
Member Avatar
+0 forum 5

Hi, I've been using tkinter to write a program that has a root window and many toplevel windows. I was able to create them successfully but my next step was to incorporate mysql with it so it would actually store any data that was entered in the various entry fields. I started with a typical script to connect to mysql with the username and password hardcoded and was able to have data saved into the database. My problem now is that I want a login window where a user will enter their own username and password and if correct, it …

Member Avatar
Member Avatar
+0 forum 3

I have an array of numbers and want to print out how many of each number there are in the array. My method works but I was wondering what a more efficient way of doing this would be. I figure a loop would work but I haven't figured out how to do it with this: [code] s='1234444432187667890000568984' print 'I found %i:' % s.count('0'),0 print 'I found %i:' % s.count('1'),1 print 'I found %i:' % s.count('2'),2 print 'I found %i:' % s.count('3'),3 print 'I found %i:' % s.count('4'),4 print 'I found %i:' % s.count('5'),5 print 'I found %i:' % s.count('6'),6 print …

Member Avatar
Member Avatar
+0 forum 2

How can I write a loop using letters instead of numbers so it looks like this: 2 sets used 'a-z' and 'A-Z' aaaaa aaaaA aaaAa aaAaa and so on: aaaAA then on to b: bbbbb bbbbA I can do it with numbers, something like this: [code] for i in range(10): for j in range(10): for k in range(10): print i,j,k [/code] How does this work with letters?

Member Avatar
Member Avatar
+0 forum 7

I'm trying to locate the 'x' positions of certain pixels. Here's and example image: [url]http://img404.imageshack.us/img404/3418/10x.png[/url] if I run this code it gives me the 88 'odd' pixels that I'm looking for: [code] from PIL import Image i = Image.open('10x.bmp') # I save it as a bmp for pixel in i.getdata(): if pixel [2] > 0: print pixel [/code] Now that I have the pixels, I can't figure out how to locate the 'x' positions. How is this done?

Member Avatar
Member Avatar
+0 forum 12

I can't seem to figure out what's wrong with this simple code. I have a user input and if it matches prints out 'That's good', if not prints out 'Too bad' but how can I get the input to ignore being case sensitive? [code] ans=raw_input("Are you feeling well today? ") if ans == "yes": print "That's good" else: print "Too bad" [/code] I want it so if someone enters "YES" it will still print "That's good"

Member Avatar
Member Avatar
+0 forum 2

I am printing out the R,G,B values of an image and get results like this: (30, 0, 0) (29, 0, 0) (28, 0, 0) (27, 0, 0) (26, 0, 0) (25, 0, 0) (24, 0, 6) (23, 0, 0) (22, 0, 0) (21, 0, 0) That is just a partial list of the values but you can see that in the one grouping it has (24,0,6) which is what I'm after. How can I get just that group or any others like it to print out, instead of the entire list? I'm assuming I need an if statement with > …

Member Avatar
Member Avatar
+0 forum 2

Hi, how can I open an image and get the R,G,B values of just the first line? [code] from PIL import Image im=Image.open("image.bmp") img=im.getcolors() print img [/code] I've tried im.getdata() , im.histogram, etc.... but again, what I'm looking for is more of R,G,B pixel counts for just the 1st line in the image.

Member Avatar
Member Avatar
+0 forum 4

Hi I'm trying to use PIL to get data from an image and find 'unusual' RBG values but haven't found the right way. [code] Import Image, PIL im=Image.open("image.bmp") ans=im.getdata() print ans [/code] This doesn't examine the RGB values for me to find any unusual ones. If tried others like: im.load() im.getpixels() im.getbands() but haven't found the right one yet.

Member Avatar
Member Avatar
+0 forum 3

I'm trying to auto send a form submission to a website but it isn't working. I've done this before and it worked but for some reason, using the same basic code, it doesn't seem to submit it. I'm using urllib & urllib2 to open the page and re to parse the info. On the page is a text entry field and a 'submit' button. I've compared the source code of both pages and they appear the same as far as the submission goes. Anything else I can try? I don't want to bother with Beautiful Soup right now because I'm …

Member Avatar
+0 forum 0

I know python has math functions like 5+6 and 5*6 and 5/6 etc...but I have something like this: x=575124357 and need to add them all together: 5+7+5+1+2+4+3+5+8=40

Member Avatar
Member Avatar
+0 forum 3

I have a randomly generated list of which contains letters, symbols, and numbers and need to separate it into 2 lists -one of numbers and one of the remaining chars. Then I need to separate the numbers into 2 lists-one of composite numbers (4,6,8,9) and one a list of prime numbers(2,3,5,7). I can make a list of the numbers, but it doesn't separate it from the list: [code] >>>s="1#%$^5hbg458#$54bjyfuig324ghal&%90a11y$#6ty7" >>>sdigits=''.join([letter for letter in s if letter.isdigit()]) >>>sdigits '1545854324901167' [/code] but if I then 'print s' the numbers are still in it. Any ideas?

Member Avatar
Member Avatar
+0 forum 2

Hi.....I have a long string of letters and symbols and I need to increment their ascii value by 1. How can I do that? Here's an example of the string: s="p@ugdyhtapbcedoamguh?a#vdaxdv$zdoxw?pu$exrbzt evk#n$xjlgpmece??$$@@yyiw##rmn$nmrblruv ?azxdsoh#$@nndkkt?k@ihatywtbazgbq#ykshx" so like # becomes $, etc

Member Avatar
Member Avatar
+0 forum 2

This code from Vegasseat worked when I made my own bitmap image to count red pixels. I now want to count green pixels so I changed the code. Again, when I make my own bitmap it will count the green pixels but why won't it count them in an image like this? [url]http://img148.imageshack.us/my.php?image=scrnyi8.png[/url] And yes, although I saved it as a png, I try it saving it as a bmp. Is it because the pixels are faint? Is there a way to make this work for an image like this? Thanks [code] # use PIL to count pixels # image …

Member Avatar
Member Avatar
+0 forum 7

I have a small image with a black background and red lines in it and I need to count the red pixels. I know I need PIL, but I'm not sure which method to use. Then once I have the counts I need to equate them to a character, so if the red lines in the image form a circle and have x amount of red pixels, its = '0', and if the image forms a straight line and is found to have x amount of pixels it's = 'l'. [code] import Image #mypic.jpg is the circle im=image.open("mypic.jpg") im.getcolors(R) # …

Member Avatar
Member Avatar
+0 forum 2

Hi, I need to write a partial ocr for just 2 characters but I don't know where to start. The 2 chars are '8' and 'F'. The 8 is only comprised of two arcs and the F is one vertical stroke and 2 horizontal strokes. I cannot use pytesser for this, at least not to read the chars. How do I go about this? Like: F = ' -, -, |' or something? or should it be an 'if' statement? I use ImageGrab.grab( ) to first get the chars, then .crop(box) to crop it to the two chars. Now what?

Member Avatar
Member Avatar
+0 forum 1

Hi, I have 2 things I'd like help with: 1) is there a way to find the exact center of my screen? 2) a loop Here's what I need the loop for: [code] image = ImageGrab.grab((0,0,800,800)) box = (100,100,400,400) im = image.crop(box) im1 = im.save("screen.jpg") # at this point I need to rotate the image 90 degrees and crop it again, but do this four times- # so I'd like a loop here instead of this: im2 = im1.rotate(90) im3 = im2.crop(box) im4 = im3.save("screen1.jpg") im5 = im4.rotate(90) im6 = im5.crop(box) im7 = im6.save("screen2.jpg") #you get the idea ;) I …

Member Avatar
Member Avatar
+0 forum 5

The End.