JoshuaBurleson 23 Posting Whiz

Instead of 1 or 0 why don't you return True or False...? Also, even though it's a bad habit of mine, it's considered ugly to use globals when not necessary in a function, you could simply return what you need to, try putting all these things in an array or hash "list or dictionary" and having them returned along with True or False.

>>> def is_good(word):
	word.capitalize()
	if word == 'Python':
		return True
	else:
		return False

	
>>> wrd='C'
>>> is_good(wrd)
False

also for changing global variables:

>>> lis=[0,1,2,3]
>>> 
>>> def plus1(that):
	new=[]
	for i in that:
		i+=1
		new.append(i)
	return new

>>> lis
[0, 1, 2, 3]
>>> lis=plus1(lis)
>>> lis
[1, 2, 3, 4]
paraclete commented: Thank you for the input +0
JoshuaBurleson 23 Posting Whiz

Well Jose,
first how would you determine this matematically?
then show us that you've written the pseudo-code.

JoshuaBurleson 23 Posting Whiz

You are not appending the list anywhere.

Computer see's list as nothing
See's someone needs to input something
See's something being printed
See's that for every interation it will print a list of nothing
And then see's more user input

and likewise:

>>>r=[]
>>> r.extend((input('Three Things: ').split()))
Three Things: my uncle bob
>>> r
['my', 'uncle', 'bob']
>>>

which could be done without the initial empty list.

JoshuaBurleson 23 Posting Whiz

here's an interesting article on the subject "I didn't even know about CubicWeb before it" http://www.itworld.com/software/192113/pillars-python-six-python-web-frameworks-compared

JoshuaBurleson 23 Posting Whiz

I just had to get this one out there. I love daniweb, and I'm sure the VAST majority of the users here do as well. And, unlike many other websites this one's community is made up of some of the greatest IT and Development minds around "as well as noobs trying to learn how to climb the ladder such as myself". In my humble opinion I believe it would be possible, maybe even a good idea to outsource some IT or Development related tasks to volunteering community members to reduce some costs "and likely make both a tighter community and an even higher grade site.

I know if I were skilled enough to actually help out I'd love to. Thoughts, comments, ideas, rebuttals?

jingda commented: Nice thought +0
JoshuaBurleson 23 Posting Whiz

You get one chance to justify why you would want to do that.

JoshuaBurleson 23 Posting Whiz

well first of all you need to think out how it should work. So, mathematically how do you find the divisors of a number? Then how would you say that in Python? Effort in effort out around here.

TrustyTony commented: Proper newbie handling, sensei ;) +13
JoshuaBurleson 23 Posting Whiz

I just finished a program

Well actually you copied the program out of the book, which with no offense to the author, isn't the greatest. I've found a large amount of the code in that book to be a bit buggy, or unclear. The way I got over that was to try to write codes that used the mechanics trying to be taught. Here, try this: write a program that takes a password and if the password is correct prints the password in a Text box, otherwise it prints the number of attempts so far in the Text box. That will be your own original code and it'll probably be easier to see where things go wrong in that as opposed to Michael Dawson's code.

JoshuaBurleson 23 Posting Whiz

abders, I would rate it an 7-8/10, it's great for learning but I can teach some bad habits and be unclear at times, but supplemented with Daniweb it can be acceptable.

JoshuaBurleson 23 Posting Whiz

Uh oh he's using the same book I was using, lol.

This worked fine for me:

from tkinter import *

class Application(Frame):
    def __init__(self, master):
        super(Application, self).__init__(master)
        self.grid()
        self.create_widgets()
        
    def create_widgets(self):
        self.bttn1 = Button(self, text ="I do nothing!")
        self.bttn1.grid()
        self.bttn2 = Button(self, text ="Me too.")
        self.bttn2.grid()
        self.bttn3 = Button(self, text ="Same here..")
        self.bttn3.grid()
        
    
root = Tk()
root.title("Lazy buttons")
root.geometry("200x100")
app = Application(root)
root.mainloop()

your issue was primarily sloppiness, pay attention to your code, you misspelled alot and forgot to call a new instance of events like grid which should've been grid()<--() is important.

Also make sure you're using python 3

JoshuaBurleson 23 Posting Whiz

Post the code here next time, and if you feel it's a good quality code post it as a snippet!

JoshuaBurleson 23 Posting Whiz

I've been on here for a few weeks now and I JUST found this CI forum, so let me apologize for the late start, "been too busy on Python". I'm a college student, but not in an IT field. Actually I've switched majors so many times it's ridiculous, Elementary Education, Criminal Justice, Social Work, Christian Ministry. I guess I just honestly don't know what I want to sit down and listen to crap about for four years. But I do love programming, I started a long time ago and then got annoyed by while loops and just put off picking it back up forever (didn't take failure well back then) but recently I picked it back up, not sure why, relearned what little I thought I knew and now, thanks to my perseverance and the help of the amazing people here at Daniweb, I dare say I'm doing pretty darn good for a beginner. I almost want to major in IT now, "although that both; is a contested field of study due to the ever changing nature of it, and I don't want to jinx something I really enjoy by majoring in it like all my other majors :D but hey, who knows. Anyways, thanks for all the help so far Daniweb, I can't wait to keep learning and help others out when I can.

kvprajapati commented: Hi! Welcome :) +0
JoshuaBurleson 23 Posting Whiz

Just so you know it's considered polite to mark the thread as solved so people can use it for future reference, and I'm sure pyTony wouldn't mind an upvote for his help if you feel it's in order.

JoshuaBurleson 23 Posting Whiz

woooee's list of tuples is quite similar to what I went with, another method would be to create a hand class and have a method to check the hand for face cards and add their values to some variable and check that total maybe something like:

class class Hand(object):
    """A black jack hand"""
    def __init__(self, cards, player,hand_val=0):
        self.cards=cards
        self.total_check(cards)
        hand_val=0
        self.player=player
    """Check the value of the hand"""
    def total_check(self, cards):
        self.hand_val=0
        for card in cards:
            if card == 'A':
                card=11
                self.hand_val+=card
            if card=='J' or card=='K' or card=='Q':
                card=10
                self.hand_val+=card
            else:
                self.hand_val+=card
        if self.hand_val>21:
            self.bust()
        else:
            self.hit_or_stay()

    def bust(self):
        print(self.cards,'=',self.hand_val,'\n', self.player,'busted!')
       
    def hit_or_stay(self):
        print('\nCurrent hand:', self.cards,'=',self.hand_val)#remember that self.cards will show the strings A J K Q
        choice=input('Would you like to hit or stay?: ')
        choice=choice.lower()
        if choice=='hit':
            self.hit()
        else:#would not actually be my first choice but I'm trying to make a point
            self.compare()
##main##        
hand=(1,'K')
player='person'
Hand(hand,player)

And in the main part of the program, or another class, depending on your style and needs, assign the hand...blah blah blah.

JoshuaBurleson 23 Posting Whiz

Just so you know, I'm also a beginner in python, and programming in general. So I used your assignment to help me with what I'm learning, Classes and methods (non-private for now). I played around a little with the idea of that and here's what I have now.

class Starship(object):
    hp=100
    fuel=100
    ammo=100
    traveled=0
    killed=0

    def __init__(self, name):
        self.name=name
        print('\nAttention Captain of Starship', self.name,'\nit\'s time to make a move!')
    def fireWeapon(self, Enemy):
        try:
            distance=int(input('\nHow far is your target?: '))
            if distance < 10:
                Enemy.hurt(50)
            elif distance > 10 and distance < 51 :
                Enemy.hurt(30)
            elif distance > 50 and distance < 76:
                Enemy.hurt(15)
            else:
                print('Lasers will not do damage at that range')
            Starship.ammo-= 1
            print('\n',Starship.ammo,'percent power left in the lasers')
            print('\nShields at',Starship.hp,'percent captain!')
        except:
            print('Invalid Entry')

    def move(self):
        try:
            lyrs=int(input('How many units would you like to travel, 1-100?: '))
            import random
            obstacle= random.randint(1,101)
            if obstacle != lyrs:
                print('Moved', lyrs,'lightyears')
            else:
                print('There is an enemy in your way!')
                Decisions.__init__()
                
            Starship.fuel-= lyrs//10
            Starship.traveled += lyrs
            return Starship.traveled, Starship.fuel
        except:
           print('\n Invalid Selection')


class Enemy(object):
    enemyhp=100
    damage1=0

    def __init__(self):
        print('I am the enemy!')
        
    def lifeCheck():
        if Enemy.enemyhp< 1:
            print('\n\nEnemy annihalated!!!\n')
            Starship.killed += 1
        else:
            print('\nEnemy shields at', Enemy.enemyhp, 'percent captain!\n')
            print('\nThe enemy is firing back!')
            import random
            chance=random.randint(1,3)
            if chance==1:
                print('\n That was close but the enemy missed!')
            else:
                import random
                attackdamage=random.randint(1,51)
                Starship.hp-=attackdamage
                print('Shit! They got us captain!')
        return Enemy.enemyhp, Starship.killed


    def hurt(damage):
        Enemy.damage1 += damage
        Enemy.enemyhp=Enemy.enemyhp-Enemy.damage1
        Enemy.lifeCheck()

    def location():
        import random
        location=random.randint(1,101)

class Decisions(object):
    def __init__(self):
        choice=input('\nenter your decisions\n1. Attack\n2. Flee\nChoice: …
TrustyTony commented: Only little bit to go: http://en.wikipedia.org/wiki/Star_Trek_%28text_game%29 +13
JoshuaBurleson 23 Posting Whiz

The common idiom is

thelist[:] = (x for x in thelist if not criteria(x))

# for example

thelist[:] = (x for x in thelist if not 'a' in x)

Python has some extraordinarily intuitive features I'm noticing, it's almost...English.