#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Am I learning Python fast enough?


    I'm working through Programming for the Absolute Beginner and I've been at it for a couple of weeks. I've just run into my first real headache. This is basically lifted from the Hangman program. And this loop had me banging my head on the table for an hour before I dissected it by making it print out variables after each loop. Now I get it.

    This seemed to stump me so much and it took me awhile to understand it. I just couldn't focus enough and see it. I'm wondering if I should be getting this stuff faster if I have any hope of doing this professionally. I like this but it's quite challenging. Are my doubts well founded or is this normal to take a little while to wrap ones head around something, as seemingly as simple as this? Thanks.

    Code:
    word = "turbo"
    so_far = "_____"
    new = ""
    
    guess = input("Enter letter guess: ")
    
    for i in range(len(word)):
    if guess == word[i]:
    		new += guess
    	else:
    		new += so_far[i]
    so_far = new
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    25
    Rep Power
    0
    Well considering you're an absolute beginner, I don't think there's anything wrong with this.
    If you've never programmed before, you're not supposed to understand the basics from the get-go. And when you do learn the basics, while you might not have trouble understanding loops, you will still have problems to solve, some of them easy, some of them quite complicated. I suggest not giving up, because, in my opinion, intellectually challenging yourself is pretty much the best thing about being a programmer.
    Have fun, and good luck

    P.S. you messed up the indentation in your code here.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0
    Thanks!

    Yes, sorry for the bad indention
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    610
    Rep Power
    65
    I have to agree that a few temporary test prints will help you understand Python code better.

    On your indentations use the standard 4 spaces. Do not use tabs, since editors are set to different tab sizes. Never mix tabs and spaces!
    Last edited by Dietrich; September 17th, 2013 at 11:58 AM.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo