Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

I have no idea why it won't run

Name: Anonymous 2012-07-16 3:41

For some reason i get a syntax error at the input near the end whenever trying to run this:
http://pastebin.com/2VR4Jdf2
 
It worked 5 minutes ago but now it won't even start running.
Which makes no sense by the way because the supposed "error" is at the bottom of the file and python is interpreted!

Name: Anonymous 2012-07-16 3:44

1. use .py extensions
2. #!/usr/bin/env python

Name: Anonymous 2012-07-16 3:54

>>2
1)I am using .py extentions
2)that did absolutely nothing.
 
Got anything else?
Does it run for you?

Name: Anonymous 2012-07-16 4:15

it runs fine here.

Name: Anonymous 2012-07-16 4:23

>>4
So is my computer broken or what?
This is really confusing...

Name: Anonymous 2012-07-16 5:23

I'm still here, and still fucked

Name: Anonymous 2012-07-16 6:30

>>6
and i still don't care

Name: Anonymous 2012-07-16 6:56

>>7
If you don't care why are you even posting?

Name: Anonymous 2012-07-16 7:20

  File "airwar.py", line 71
    choice=input('Play again?\n')
         ^
SyntaxError: invalid syntax


It says it right there.. it is not expecting that sort of statement. So if you look, your line 71 is INSIDE the paren opened on line 69.
dealto(ehand, edeck, len(ehand)
dealto(ehand, edeck, len(ehand))

your welcome

Name: Anonymous 2012-07-16 7:35

Let's paste the whole code so we could laugh at >>1-kun long after the pastebin is gone and some idiot or spambot bumps this thread on 2015 or so.

airwar.py

from deck import *
import random
from collections import deque

while True:
#init
    gamenotover=True
    deck=deque()
    edeck=deque()
    hand=deque()
    ehand=deque()
    filldeck(deck)
    filldeck(edeck)
    random.shuffle(deck)
    random.shuffle(edeck)
    cardsleft=52
    ecardsleft=52

#game start
    while gamenotover:
        print '\n%r'%(cardsleft)
        print '\n%r'%(ecardsleft)
        if cardsleft<5:
            print '\nYou lose.'
            gamenotover=False
        elif ecardsleft<5:
            print '\nYou win!'
            gamenotover=False

#deal
        else:
            pcardsleft=dealto(deck, hand, 5)
            ecardsleft=dealto(edeck, ehand, 5)
           
            print '\nYour opponent\'s hand is:'
            for card in hand:
                print display(card)
            print "\nYour hand is:"
            for card in ehand:
                print display(card)
#choose order
                #pass
#battle
            dlist=deque()
            edlist=deque()
            for i in range(5):
                print '\ncard:%r ecard:%r'\
                      %(display(hand[i]), display(ehand[i]))
                if ehand[i][1]>hand[i][1]:
                    dlist.append(hand[i])
                    print 'deleted card:%r'%(display(hand[i]))
                elif hand[i][1]>ehand[i][1]:
                    edlist.append(ehand[i])
                    print 'deleted ecard:%r'%(display(ehand[i]))
                elif hand[i][1]==ehand[i][1]:
                    pass
            if dlist:
                for card in dlist:
                    print '\ncard:%r'%(display(card))
                    hand.remove(card)
            if edlist:
                for ecard in edlist:
                    print '\necard: %r'%(display(ecard))
                    ehand.remove(ecard)
#ready for next turn
            if hand:
                dealto(hand, deck, len(hand))
            if ehand:
                dealto(ehand, edeck, len(ehand)
                      
    choice=input('Play again?\n')
    if choice[0]=='y' or choice[0]=='Y':
        pass
    else:
        break


deck.py

from collections import deque


def filldeck(deck):
    for i in range(52):
        deck.append(((i/13)+1, (i%13)+1))
    return deck

def display(card):
    if card:
        suits=['hearts', 'clubs', 'diamonds', 'spades']
        names=['Ace', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight',\
        'Nine', 'Ten', 'Jack', 'Queen', 'King']
       
        return '%r of %r'%(names[card[1]-1], suits[card[0]-1])

def dealto(deck1, deck2, number):
    if number>len(deck1):
        number=len(deck1)
    for i in range(number):
        deck2.append(deck1.popleft())
    return len(deck1)

##deck=deque()
##filldeck(deck)
##for card in deck:
##    display(card)

Name: Anonymous 2012-07-16 7:37

by the way, you're code is horrible and amunsingly unpythonic

Name: GAYDO VAN ROSSUM 2012-07-16 7:43

>>11
It's beautiful!

Name: Anonymous 2012-07-16 9:04

>>9
Thanks.
It would sure be nice if it could mention something about parthesis or highlight completed pairs or something though.

Name: Anonymous 2012-07-16 9:04

>>10
In order to preserve my legacy I have only one thing to say:
It works, deal with it.

Name: Anonymous 2012-07-16 9:15

And you know you'd get a lot less people doing it wrong if you provided some examples of "doing it right"

Name: Anonymous 2012-07-16 9:16

bump

Name: Anonymous 2012-07-16 9:23

>>16
Who the hell are you?
Haven't I debased myself enough infront of you people?

Name: Anonymous 2012-07-16 9:32

/ONE WORD THE FUCKING SHITTINESS OF FIOC THREAD FUCKING OVER GOD DAMMIT/

Name: Anonymous 2012-07-16 9:43

>>18
NOPE
Though I do hate it.
C had more freedumb. Though only with formatting.

Name: Anonymous 2012-07-16 14:00

>>15
Sorry, you want /prog to start posting example code threads? Though, if you want interesting snippets of good code then I suggest you start browsing the threads from ~2007 when this board could still produce mind-fucking LITHPu and decent C.

Name: Anonymous 2012-07-16 16:05

/BOX/

Name: Anonymous 2012-07-16 16:21

>>15,20
Use this to guide you in your quest for Satori:
http://dis.4chan.org/read/prog/1339846025

Name: Anonymous 2012-07-16 19:07

>>22
If it's Python it ain't Lisp.
If it ain't Lisp it's crap.

Name: Anonymous 2012-07-16 19:50

>>23
But if it's Lisp, it's shit.
If it ain't shit, it's crap.

Name: Anonymous 2012-07-17 2:23

LISP is the shit.

Don't change these.
Name: Email:
Entire Thread Thread List