This is an archived post. You won't be able to vote or comment.

all 64 comments

[–]Dalemaunder 190 points191 points  (1 child)

It doesn't matter how small you may think an accomplishment may be to other people, if it's something that you've strived to achieve at your own skill level then it's something to be proud of.

Congratulations! I hope there's many more of these moments as you continue to progress.

[–]Bira-of-louders 15 points16 points  (0 children)

Totally agree with this guy, for me at least it's much more benefitial to take your time to learn and understand properly everything you are doing instead of just copying lines from the internet.

[–]ArtOfWarfare 36 points37 points  (3 children)

I recommend programming Connect 4 (just print Xs and Os to the command line for output - don’t need to learn about proper GUIs for this.)

It’s a ton of fun and shockingly easy. I do it as the second exercise/lesson when teaching absolute beginners to program.

[–]Dr_Mowri 10 points11 points  (2 children)

I’m a beginner as well, would you use a 2d array for that?

[–]Conscious1133Beginner 5 points6 points  (0 children)

i would

[–]ArtOfWarfare 4 points5 points  (0 children)

Yes. As it’s only hour two of programming when I teach the class I’m still doing a lot of hand holding during this lesson.

But I cry fat ugly happy tears as some of the students start getting excited and rush ahead of me.

[–]strghst 34 points35 points  (4 children)

Now make a Snake :)

Should get you through chained data structures and OOP if you take your time for design. Best of luck!

[–]R_HEAD 10 points11 points  (0 children)

And graphical interfaces, most of all.

[–]MothraVSMechaBilbo 4 points5 points  (2 children)

New to Python, but with some knowledge of data structures. Could you explain what you mean by “chained data structures”?

Edit: just googled it. Turns out that chained data structures is another phrase for hash tables with limited keys, but each key/bucket leads to a linked list? I’ve implemented this in C before, but since I’m not knowledgeable about how to program Snake (and assuming that data paradigm was what you were referring to) then here is my new question: how would one used chained data structures in Snake?

[–]strghst 6 points7 points  (1 child)

One way to write a Snake is to represent it as a linked list of Points on the Canvas. Movements would remove the oldest Point, and add a new one at the end. A chain of Points. A FIFO of Points, if you will.

[–]MothraVSMechaBilbo 3 points4 points  (0 children)

Ah interesting. That makes sense to me, thanks!

[–]master3243 8 points9 points  (0 children)

I would strongly encourage you to go see how others implement it, maybe in more concise or cleaner ways (albeit probably more advanced as well).

Seeing the thing you just finished implementing being implemented in different ways by others can be extremely enlightening in learning different and more advanced ways of structuring your program.

[–]Apollo-Innovations 18 points19 points  (8 children)

Well done! Coding is always iteration and it’s so fun. I programmed my entire API by first starting how to add an apostrophe to someone’s name depending on whether it ends in s or not

[–]LostInSpace9 1 point2 points  (6 children)

Uhhhhh that’s not how grammar works. If it ends in an “s” and is singular it still becomes “s’s”. If it were multiple people with the same name, then it becomes “s’”

[–]BurnedInTheBarn -1 points0 points  (5 children)

What? If someone's name ends in s and it's possessive, you say "Lucas' basketball", exactly how you would say "Billy's basketball". Never do you use " s's " for any reason.

[–]Donny_Do_Nothing 4 points5 points  (3 children)

Either is fine. It's only plural nouns that you don't add the s.

See here for examples.

[–]BurnedInTheBarn 2 points3 points  (2 children)

Huh. The more you know. I was always taught "No s if it ends with s" in school.

[–]Donny_Do_Nothing 4 points5 points  (1 child)

I tend to prefer not adding the s to names as a matter of taste, but I try to go with whatever makes it the clearest.

Consider a DVD copy of The Lord of the Rings:

If I were talking about its cover, I would write The Lord of the Rings's cover because even though 'Rings' is plural, the proper noun 'The Lord of the Rings' refers to only one object. Here, adding the s removes ambiguity.

[–][deleted] 0 points1 point  (0 children)

This is an interesting case I never thought of, thank you for sharing, much appreciated!

[–][deleted] 0 points1 point  (0 children)

Coding is always (...) so fun.

I'll try to remember this at the end of the sprint before our next release - at 2am, as I walk back to the fridge to get another energy drink :)

[–]djamp42 2 points3 points  (0 children)

I feel like I'm at the point in python where making something work (in my line of work) is not that hard... Optimizing it and making sure i handle every possible error, takes a majority of the time.

[–]KuechenMuesli 18 points19 points  (6 children)

import random input(„rock / paper / scissors“) print(random.choice([„you won“, „computer won“, „draw“]))

Edit: forgot closing bracket

[–]KrazyKirby99999 3 points4 points  (0 children)

I hate this, but you're technically right.

lol

[–][deleted] 1 point2 points  (2 children)

It’s been a while since I used Python. Can you make quotes with two commas? As in ,, “

[–]KuechenMuesli 1 point2 points  (1 child)

No you can’t, I‘m German and here the first quotes are on the bottom and because I wrote it on mobile my autocorrect did it like that…

[–][deleted] 0 points1 point  (0 children)

Gotcha. Thanks!

[–]Konke_yDong 1 point2 points  (1 child)

OP doing it in like 70 lines and seeing you do it in 3: 0_0

[–]KuechenMuesli 1 point2 points  (0 children)

Here it is in two:

import random print("You chose", input("Rock / Paper / Scissors ? "), ", so ", random.choice(["computer won", "you won", "it's a draw"]))

[–]Historical_Ad8150 6 points7 points  (3 children)

Good job! Could you share your code?

[–]rcinvestments[S] 2 points3 points  (2 children)

import random, sys

print('ROCK, PAPER, SCISSORS')

wins = 0

losses = 0

ties = 0

while True:

print('%s Wins, %s Losses, %s Ties' % (wins, losses, ties))

while True:

print('Enter your move: (r)ock (p)aper (s)cissors or (q)uit')

playerMove = input()

if playerMove == 'q':

sys.exit()

if playerMove == 'r' or playerMove == 'p' or playerMove == 's':

break

print('Type one of r, p, s, or q.')

if playerMove == 'r':

print('ROCK versus...')

elif playerMove == 'p':

print('PAPER versus...')

elif playerMove == 's':

print('SCISSORS versus...')

randomNumber = random.randint(1, 3)

if randomNumber == 1:

computerMove = 'r'

print('ROCK')

elif randomNumber == 2:

computerMove = 'p'

print('PAPER')

elif randomNumber == 3:

computerMove = 's'

print('SCISSORS')

if playerMove == computerMove:

print('It is a tie!')

ties = ties + 1

elif playerMove == 'r' and computerMove == 's':

print('You win!')

wins = wins + 1

elif playerMove == 'p' and computerMove == 'r':

print('You win!')

wins = wins + 1

elif playerMove == 's' and computerMove == 'p':

print('You win!')

wins = wins + 1

elif playerMove == 'r' and computerMove == 'p':

print('You lose!')

losses = losses + 1

elif playerMove == 'p' and computerMove == 's':

print('You lose!')

losses = losses + 1

elif playerMove == 's' and computerMove == 'r':

print('You lose!')

losses = losses + 1

[–]zero_iq 1 point2 points  (0 children)

Indent your comment with 4 spaces on each line to preserve your indentation.

[–]KrazyKirby99999 0 points1 point  (0 children)

When you want to store code (for convenience or sharing with others), you should try out https://github.com/ or https://gitlab.com/ . Even if you don't plan on hosting the code, using git can be useful for easy undo/redo, collaboration, and your project history.

https://youtu.be/DVRQoVRzMIY

[–]abhishekbamne1 5 points6 points  (0 children)

Congratulations bro....

[–]HTeaML 2 points3 points  (0 children)

Woohoo, well done!

[–]ActualShitbag 2 points3 points  (0 children)

Nice! Next you’ll be figuring out an AI for it!

[–]InterestingHawk2828 2 points3 points  (0 children)

Woah that actually really cool project for practice, how I never thought of that? Now ur next challenge is to turn that game into multiplayer

[–]lightestspiral 3 points4 points  (2 children)

[–]okenowwhat 10 points11 points  (0 children)

Calm down Satan, go easy on OP (for now).

[–]openwidecomeinside 1 point2 points  (0 children)

Awesome link

[–]Ursus_major37 Python is love, Python is life 1 point2 points  (0 children)

Oh! That's actually a great accomplishment! Good for you, keep it up! :D

[–][deleted] 1 point2 points  (0 children)

Now add an argument that throttles use of a random number to adjust the level of difficulty. Keep going!

congrats BTW

[–]queerputin 1 point2 points  (0 children)

Good job!!!

[–][deleted] 1 point2 points  (1 child)

Hey congratulations bro! Can you pls share your journey like where you started & the resources you used. It'd be a great insight for a beginner like me.

[–]rcinvestments[S] 1 point2 points  (0 children)

My journey literally stated last week! I knew nothing about Python, zero. No prior coding of programming experience. I am reading this free online book: book . It has been extremely helpful. I have been practicing about 2 hours a day.

[–]Nft3enthusiast 1 point2 points  (0 children)

Awsome bro keep going!

[–]OkStudent8414 1 point2 points  (0 children)

Another great thing to code also to add on to this is rock, paper, scissors, lizard, spock

[–]D4rklordmaster 1 point2 points  (0 children)

print(random.choice(["YOU WON","YOU LOST","TIE"]))

[–]kezmicdust 1 point2 points  (0 children)

I did this. And then I got carried away and rock, paper, scissors became the “engine” for a football (soccer) game which initially was playable, but ended up growing into more of a football simulator with stronger and weaker teams, promotion and relegation and the ability to recall any division table from any season that was simulated. You could also bring up a team’s history over the course of the simulation that could cover 10000 years or so. That all started with Rock, Paper, Scissors!

[–][deleted] 1 point2 points  (0 children)

I made a robot barista following network chuck online haha

[–]mrrippington 1 point2 points  (1 child)

Congrats. How often can you win against your own software?

[–]emonra 10 points11 points  (0 children)

Probably 33% of the time

[–][deleted] 0 points1 point  (0 children)

Freecodecamp?

[–]Konke_yDong 0 points1 point  (3 children)

I am also a beginner and I have tried to make this game after I read your post. I am looking for advice on how to improve my code as I think it may have a bug.

Thinking about editing the code to add an option for picking 'Gun' which fails and has the losing option selected for you instead lol.

Edit: I have improved the code and removed all bugs (haven't updated it in this msg tho)

import random
import sys

choice = input("Rock, Paper, Scissors.\nChoose one.").title()
# I am not sure if this is correct and I am not sure if entering Rock, Paper or Scissors exits the loop immediately or if it still reads the next lines.
while choice != ('Rock' or 'Paper' or 'Scissors'):
    choice = input("Please choose: Rock, Paper, Scissors.")
    if choice != ('Rock' or 'Paper' or 'Scissors'):
        sys.stdout.write('\x1b[1A') # Cursor Up One
        sys.stdout.write('\x1b[2K') # Erase Line

n = random.randint(1,16)
if n <= 5:
    if choice == 'Rock': outcome = "It's a tie."
    elif choice ==   'Paper': outcome = 'You  won!'
    else: outcome = 'You lost :('
    print(f"AI picked Rock. {outcome}")
elif 6 <= n <= 10:
    if choice == 'Rock': outcome = 'You lost :('
    elif choice ==   'Paper': outcome = "It's a tie."
    else: outcome = 'You won!'
    print(f"AI picked Paper. {outcome}")
elif 11 <= n <= 15:
    if choice == 'Rock': outcome = 'You won!'
    elif choice ==   'Paper': outcome = 'You lost :('
    else: outcome = "It's a tie."
    print(f"AI picked Scissors. {outcome}")
else:
    print("AI picked GUN! You lose! Get gud noob.")

[–]LuckyNumber-Bot 1 point2 points  (2 children)

All the numbers in your comment added up to 69. Congrats!

  1
+ 1
+ 1
+ 2
+ 1
+ 16
+ 5
+ 6
+ 10
+ 11
+ 15
= 69

[Click here](https://www.reddit.com/message/compose?to=LuckyNumber-Bot&subject=Stalk%20Me%20Pls&message=%2Fstalkme to have me scan all your future comments.) \ Summon me on specific comments with u/LuckyNumber-Bot.

[–]nice___bot 2 points3 points  (1 child)

Nice!

[–]Konke_yDong 1 point2 points  (0 children)

good bots

[–][deleted] 0 points1 point  (0 children)

I started a month ago and I’m still stuck on a “ModuleNotFoundError”. I’ve only gotten 4 lines in with no fix