[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

What is wrong with my program?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 20
Thread images: 1

File: public pc - admin status.jpg (863KB, 2010x3167px) Image search: [Google]
public pc - admin status.jpg
863KB, 2010x3167px
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
Thread posts: 20
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.