Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gambling Script Help
#1
hey guys.

I'm making a gambling script(will be posting it soon) but am i running against a problem.

error:
Code:
Traceback (most recent call last):
  File "C:\Python26\py2exe GUI\Kopie van gambling proto.py", line 217, in <module>
    print "You won by colour! Profit: "+rnwoncash
TypeError: cannot concatenate 'str' and 'int' objects

script part:
Code:
elif rnuserchosencolour==rnchosencolour:
            (line217)print "You won by colour! Profit: "+rnwoncash
                        rmoney+=rnwoncash
    (this last lines are to stop looping)
                        xxx-=1
                        rightnumberbet-=1
                        rightbet-=1
                        wrongin-=1


so can you guys help me?( rnwoncash is a number)
Reply
#2
(10-19-2009, 09:20 AM)Mr.FeellingLeSS Wrote: (line217)print "You won by colour! Profit: "+rnwoncash

Change the line to

Code:
print "You won by colour! Profit: ", rnwoncash

In Python you get a problem when you use "+" with 2 different types of data, since your var "rnwoncash" is integer you can't use "+" to add it to your string...
Reply
#3
(10-19-2009, 09:24 AM)NinjaGeek Wrote: Change the line to

Code:
print "You won by colour! Profit: ", rnwoncash

In Python you get a problem when you use "+" with 2 different types of data, since your var "rnwoncash" is integer you can't use "+" to add it to your string...

thanks for the quick respone i will change it. PirateThumbsupBig Grin
Reply
#4
(10-19-2009, 09:32 AM)Mr.FeellingLeSS Wrote: thanks for the quick respone i will change it. PirateThumbsupBig Grin

Blackhat
I'm here to help, and for the future please use the code tags when showing code snippets

Code:
[code]Your code [ /code](without the whitespace in the closing tag)
Reply
#5
(10-19-2009, 09:35 AM)NinjaGeek Wrote: Blackhat
I'm here to help, and for the future please use the code tags when showing code snippets

Code:
[code]Your code [ /code](without the whitespace in the closing tag)

taken care of Thumbsup
Reply
#6
Please don't change thread titles into nonsense.
Superman I am here to rescue you.
This is Support Forums not Support PMs.  Do not PM me for support unless it's private and site related.
Reply
#7
since rnwoncash is an int, to concentrate it with a string you must turn it into a string.

Code:
print "You won by colour! Profit: " + str( rnwoncash )

should do
[Image: nv70ad.png]
Terrorcore, unleash, extermination
Hyper real, cold blood, determination
fudge them, I like this sensation
Incredible, I from the annihilation
Reply
#8
guys i got an other problem Gratte

Code:
import os
import platform
systemver=platform.release()
if systemver=='XP':
    clearer=os.system("cls")
elif systemver=='Vista':
    clearer==os.system("clear")
else:
    clearer==os.system("clear")
clearer
print "TEST TEXT"
clearer
print "TEST LTEXT"
raw_input("")

it won't clear, though i don't get a error...
it just skips clearer like it means nothing...
Reply
#9
(10-20-2009, 10:06 AM)Mr.FeellingLeSS Wrote: it won't clear, though i don't get a error...
it just skips clearer like it means nothing...

It does clear on XP, what are you using Vista or 7?

EDIT:
aahhhh I got what you were trying to do, you are calling the variable "clearer" but that is the wrong way
try defining a function, try this:
Code:
import os
import platform

def clearer():
    systemver=platform.release()
    if systemver=='XP':
        os.system("cls")
    elif systemver=='Vista':
        os.system("clear")
    else:
        os.system("clear")

clearer()
print "TEST TEXT"
clearer()
print "TEST LTEXT"
raw_input("")
Reply
#10
Thanks for the quick response Thumbsup

i see what i did wrong fixing it now Big Grin[/align]
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)