Can someone tell me wtf is wrong with my program?
I'm trying to make a blackjack program for my homework assignment, and it won't even run.import random
def main():
total=0
eval (input("you want to play blackjack? 1 for yes, 2 for no.))
if input == 1
drawone=(rand.randint(1,10))
total=total+drawone
print ("your total is", total)
print ("drawing your second card")
drawtwo=(rand.randint(1,10))
total=total+drawtwo
print ("your total is", total)
print ("drawing your third card")
drawthree=(rand.randint(1,10))
total=total+drawthree
if total>21
print ("haha you lose")
if (total<=21) and (total>=18)
print("you were counting cards, get out of my casino")
while total<18
drawmore=(rand.randint(1,10))
total=total+drawmore
if total>21
print ("haha you lose")
if total==21
print("you were counting cards, get out of my casino")
else
print ("then get out of my casino")
main()
>>56689769
you forgot to put ':' after if and else statements
>>56690222
kk. i'll do that real quick. pls stay though. thanks for the help by the way
>>56690222
so I added fixed up the syntax, but for whatever reason,
the program will run the first print statement, i'll type "1", then hit enter,
and it will type "then get out of my casino" and the program will end.
Why does it skip the whole first block of code?import random
def main():
total=0
eval (input("you want to play blackjack? 1 for yes, 2 for no."))
if input == 1:
drawone=(rand.randint(1,10))
total=total+drawone
print ("your total is", total)
print ("drawing your second card")
drawtwo=(rand.randint(1,10))
total=total+drawtwo
print ("your total is", total)
print ("drawing your third card")
drawthree=(rand.randint(1,10))
total=total+drawthree
if total>21:
print ("haha you lose")
if (total<=21) and (total>=18):
print("you were counting cards, get out of my casino")
while total<18:
drawmore=(rand.randint(1,10))
total=total+drawmore
if total>21:
print ("haha you lose")
if total==21:
print("you were counting cards, get out of my casino")
else:
print ("then get out of my casino")
main()
>>56690322
Mmmm... why you don't change the line that has an eval statement and put it like this:
usr_input = input(".....put whatever you want....")
And then instead of "if input == 1" just make this:
"if usr_input == 1"
>>56690392
ok. i'll try that.
curious, though, what is the difference? im new to programming btw
p.s. this is python. I forgot to mention that
>>56690431
I'm not to experienced with python but I read somewhere that eval is a function which lets you execute python-code in runtime, the other one is just variable declaration
>>56690524
ok. I think i'm gonna keep eval the same then.
My professor uses eval the same way, so I don't think substituting for usr_input will fix it.
It's probably a problem with something else.
thanks for the help though.
>>56690616
ok, but if im not wrong eval returns strings so it may be " if input == '1': "
>>56690639
not sure what you mean by that. the assignment is due in 8 minutes, so i'm just gonna turn it in as is.
>>56690665
even though I will have turned it in,
if anyone is still willing to tell me what's up with the program, I would be glad to hear it
>>56690702
Good luck, sorry for not giving enough advice, but I want to know wich version of python do you have?
>>56690731
Pretty sure it's the latest. I downloaded it 2-3 weeks ago. I'm using the native IDLE python text editor. I tried using sublime, but I didn't want to waste time figuring it out, at least not with an assignment due soon.
>>56690761
So your python version is 3.5?
>>56690776
yeah, just checked
>>56690776
>>56690789
why do you ask?
Trying ti make a online casino website op? Want to join forces? Doing the same here but not in python drop a email if u want
>>56692069
> online casino website
>>56693324
Yes to be sure its not about a offline little game. im high as fuck m8
>>56689769
>>56690322
christ, haven't seen wrose b8 m8 i r8 0/8