I bookmarked all the links you guys posted, and the code design stuff sounds pretty useful, for later on at least.
This is the book series I've been using. I read chapter 1 in the one I'm linking directly, but I am on chapter 4 of "Invent your own games with Python". These seem fairly short, and I will probably be able to finish this book in a month or so. I plan on doing the other ones too, and finding any and all sources of information that I can.
Here is the first thing I wrote (after hello world, that is).
# This is a simple guess the number game. import random guessesTaken = 0 print('#############################') print('# Hello! What is your name? #') print('#############################') myName = input() number = random.randint(1, 20) print('Well, ' + myName + ', I am thinking of a number between 1 and 20') for guessesTaken in range(6): print('Take a guess!') # Four spaces here guess = input() guess = int(guess) if guess < number: print('Your guess is too low :(') # eight spaces here if guess > number: print('Your guess is too high :/') if guess == number: break if guess == number: guessesTaken = str(guessesTaken + 1) print('Good job, ' + myName + '! You guessed the number in ' + guessesTaken + ' guesses!') print() print('Thanks for playing!') if guess != number: number = str(number) print('Nope. The number I was thinking of was ' + number +'.') print() print('Thanks for playing!')
The next chapter talks about defining your own functions, and making it so the program knows if you gave a valid answer. For example, this 'game' only accepts numbers as an answer. When you type in the number 5, it is a string, not an integer, so the int() function makes that input into an integer, but only if it is an actual number. But you guys know this stuff anyway . Currently, if you enter anything that isn't a whole number, you'll get an error. But I can make a function that tells you that is invalid, and asks for a number.
I also made this before learning about line breaks within strings, so I used three print() functions there at the top. Small steps!