Hey there guys, been looking into sockets in python recently but i'm having a little trouble getting my program to work rite.
It's just a random number generator game but I want to make it available over a network. So people can connect, play and then quit. I know how to open a socket then close it. I've done the basic examples in some tutorials but what I don't get(and i'm sure it's something stupid that i'm just not realising) is how to actually incorporate it into my program.
That's the game. I'm sure it's pretty ugly code so if anyones got any suggestions on how to clean it up that would also be cool.Code:print "Hello, World!" #I put "Hello World" into all of my programs. Just as a kind of good practise thing. # Guessing Game import random # Start while loop number = random.randrange(1,100) guess = 0 while guess != number: guess = int(raw_input("What is your guess? ")) if guess == number: print "Well done you got it!" elif guess < number: print "Sorry it's higher than that" elif guess > number: print "Sorry it's lower than that" else: break print print "Thanks for playing random!"
Bookmarks