Jump to content

JAMJAR

Member
  • Posts

    9
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by JAMJAR

  1. Well I finally figured it out I know all through the course Stefan had stressed time and time again about the importance of spaces in Python and I did believe him I just hadn't really learnt the lesson very well until now. So I was determined not to be beaten by this problem with my code, but no matter how many times I looked at my code and compared it to the source code I just couldn't see my fault. Not wanting to move onto the next lesson without fixing my code I decided I'd have to keep checking and re checking until I found my mistake. There it was as plain as day........ SPACING! how could I miss that?? Well I'm not entirely sure how I missed it, but I'm glad i did, I've learnt a very valuable lesson today For comparisons sake heres my newly spaced code: # Python treasure hunt game import random, time def display_game_intro(): print(''' ---->Welcome to the 'Python Treasure Hunt Game' ...the most amazing game ever made! After a long journey, you find yourself in front of two caves. One cave leads to a treasure, the other, a spike filled pit! Being brave, and a little greedy for treasure, you've decided to go for it! ''') def choose_cave(): cave = '' while cave != '1' and cave != '2': print('Which cave do you want to enter? (1 or 2)') cave = input() return cave def enter_cave(chosen_cave): print('\nYou have entered a cave...') time.sleep(1) random_cave = random.randint(1,2) #print("random_cave= " + str(random_cave)) if random_cave == int(chosen_cave): print("---> Lucky you! You found the chest!") else: print("--->You expected to find a chest\n ...and all you found was DEATH!") def main_loop(): ''' The main_loop() function controls the flow of the game by calling functions and using conditionals''' playGameAgain = "yes" while playGameAgain == "yes" or playGameAgain == "y": display_game_intro() chosen_cave = choose_cave() enter_cave(chosen_cave) print("\n\nDo you want to try again? (yes or no)") playGameAgain = input() print("You said: " + playGameAgain) time.sleep(1) if playGameAgain == "yes" or playGameAgain == "y": print("\nLet's try again!") else: print("\nOk, see ya later!") main_loop()
  2. The only thing I can see in the source code that is different from my typed code is the spelling difference in choosen (from source) and I typed chosen. Please help this is driving me nuts.
  3. Just for the record (In case anybody would like to check my typed code vs the source code, I will include it here: # Python Treasure Hunt Game # Finding a simple data type bug. import random, time def display_game_intro(): print(''' ----> Welcome to the 'Python Treasure Hunt Game' ... the most amazing game ever made! After a long journey, you find yourself in front of two caves. One cave leads to a treasure, the other, a spike filled pit! Being brave, and a little greedy for treasure, you've decided to go for it! ''') def choose_cave(): cave = '' while cave != '1' and cave != '2': print('Which cave do you want to enter? (1 or 2)') cave = input() return cave def enter_cave(choosen_cave): print('\nYou have entered a cave ...') time.sleep(1) random_cave = random.randint(1,2) #print("randon_cave= " + str(random_cave)) if random_cave == int(choosen_cave): print("---> Lucky you! You found the chest!") else: print("---> You expected to find a chest\n ...and all you found was DEATH!") def main_loop(): ''' The main_loop() function controls the flow of the game by calling functions and using conditionals''' playGameAgain = "yes" while playGameAgain == "yes" or playGameAgain == "y": display_game_intro() chosen_cave = choose_cave() enter_cave(chosen_cave) print("\n\nDo you want to try again? (yes or no)") playGameAgain = input() print("You said: " + playGameAgain) time.sleep(1) if playGameAgain == "yes" or playGameAgain == "y": print("\nLet's try again!") else: print("\nOk, see ya later!") main_loop()
  4. Hi I'm currently working my way through Stef's Python course (which is great btw) I'm upto finalising the treasure hunt game code, but when I run it, it's not asking me if I'd like to play again it's just going straight to which cave would you like to choose. I've been following along and typing all my own code as opposed to just copying and pasting from the source file. I've even pulled up the source file and just can't see what I've done wrong or differently. This has been bugging me for a few days now, can anyone advise please? here's my copy of the code: # Python treasure hunt game import random, time def display_game_intro(): print(''' ---->Welcome to the 'Python Treasure Hunt Game' ...the most amazing game ever made! After a long journey, you find yourself in front of two caves. One cave leads to a treasure, the other, a spike filled pit! Being brave, and a little greedy for treasure, you've decided to go for it! ''') def choose_cave(): cave = '' while cave != '1' and cave != '2': print('Which cave do you want to enter? (1 or 2)') cave = input() return cave def enter_cave(chosen_cave): print('\nYou have entered a cave...') time.sleep(1) random_cave = random.randint(1,2) #print("random_cave= " + str(random_cave)) if random_cave == int(chosen_cave): print("---> Lucky you! You found the chest!") else: print("--->You expected to find a chest\n ...and all you found was DEATH!") def main_loop(): ''' The main_loop() function controls the flow of the game by calling functions and using conditionals''' playGameAgain = "yes" while playGameAgain == "yes" or playGameAgain == "y": display_game_intro() chosen_cave = choose_cave() enter_cave(chosen_cave) print("\n\nDo you want to try again? (yes or no)") playGameAgain = input() print("You said: " + playGameAgain) time.sleep(1) if playGameAgain == "yes" or playGameAgain == "y": print("\nLet's try again!") else: print("\nOk, see you later!") main_loop()
  5. Hi everyone I'm totally new to programming but I really want to learn. I'd been struggling trying to teach myself from books & various websites for about 6 weeks, then I bought Stefan's Python course. Since then I've started to grasp simple things like variables, loops etc. But I do have a concern, I'm worried as I'm working my way through the videos I'll not remember certain things, I'm wondering what you would suggest would be the best way to learn? Should I just keep working through the videos in the hope that things will just 'click' and sink in? Or is there a preferred method, like maybe watching the same video over and over and over and....... you get the idea right? I just want to maximise my learning experience. How did you learn? Any advice or help would be hugely appreciated. Thanks
  6. Hey Stef, I really am enjoying your python course I feel like I'm able to understand the terminologies much better with your analogies. I'm taking my time with it though and really going through the videos slowly to make sure I am really 'getting it' and don't want to burn out by trying to cram too much into my brain in a shorter period of time. I'm trying to do an hour or so a day at the moment but plan on upping my study time to 5-6 hours a day in the next couple of weeks. A quick question though: How long would you estimate it will take me or the average person (with no previous computing skills) to become proficient with python? Thanks for all your help
  7. Hey LSW, I hope I haven't caused any offence I've just been very frustrated lately, I have no previous experience of computing or IT work, I can just about find my way around a keyboard I've started watching Stefans videos and I'm shocked at how easily I'm starting to understand now. Maybe I'm not too old after all? Thanks for the warm welcome
  8. Hi everyone I'm Jamjar (not my real name) I'm from Manchester, England UK. I'm currently on the wrong side of 40 wondering what the hell am I doing..... (This is a young persons game right?) I've been trying to learn Python from books & online resources, today I've been pulling out (what's left of) my hair, I was about ready to call it a day, then on my YouTube feed was suggested one of Stefan's videos about learning to code over 40. I decided it couldn't hurt to watch one last video before I succumbed to old age & bought myself a bag of werthers and a cardigan! After watching the video I genuinely felt motivated, I left a comment & Stefan suggested his Python video course, anyway I've bought the course but don't think I'll start it until tomorrow as I'm ever so slightly stressed today. My biggest problem to date in trying to learn python is I don't understand any of the terms used, I don't understand why I'm typing these seemingly odd words or what they do..... But most of all I just don't seem to remember anything Anyway thank you for reading and I hope I haven't bored you all too much and hopefully I wont irritate you with all my noob questions
×
×
  • Create New...