Skip to main content
Improved formatting of the pure text code block
Source Link
$ python3 test.py
Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.


    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.

Your choice? D
Your camel feels refreshed and happy his fatigue is now  0
Traceback (most recent call last):
  File "test.py", line 73, in <module>
    if oasis == 20:
NameError: name 'oasis' is not defined
$ python3 test.py
Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.


    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.

Your choice? D
Your camel feels refreshed and happy his fatigue is now  0
Traceback (most recent call last):
  File "test.py", line 73, in <module>
    if oasis == 20:
NameError: name 'oasis' is not defined
$ python3 test.py
Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.


    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.

Your choice? D
Your camel feels refreshed and happy his fatigue is now  0
Traceback (most recent call last):
  File "test.py", line 73, in <module>
    if oasis == 20:
NameError: name 'oasis' is not defined
$ python3 test.py
Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.


    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.

Your choice? D
Your camel feels refreshed and happy his fatigue is now  0
Traceback (most recent call last):
  File "test.py", line 73, in <module>
    if oasis == 20:
NameError: name 'oasis' is not defined
added 91 characters in body
Source Link
Spikatrix
  • 1k
  • 1
  • 9
  • 21
  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  4. You have

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    

    You should also have an else printing an error message in case the user enters something invalid. Like so:

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    else:
        print("Invalid input; Try again") # Print error message
    
  5. You can also print how much thirsty you are when the user selects "E"(status check)

  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  4. You have

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    

    You should also have an else printing an error message in case the user enters something invalid. Like so:

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    else:
        print("Invalid input; Try again") # Print error message
    
  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  4. You have

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    

    You should also have an else printing an error message in case the user enters something invalid. Like so:

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    else:
        print("Invalid input; Try again") # Print error message
    
  5. You can also print how much thirsty you are when the user selects "E"(status check)

added 912 characters in body
Source Link
Spikatrix
  • 1k
  • 1
  • 9
  • 21
  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  4. You have

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    

    You should also have an else printing an error message in case the user enters something invalid. Like so:

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    else:
        print("Invalid input; Try again") # Print error message
    
  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  1. This

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
    print()
    

    can be written as

    print("Welcome to Camel!")
    print("""You have stolen a camel to make your way across the great Mobi desert.
    The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.\n""")
    

    Similarly,

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.""")
    print()
    

    can be written as

    print("""
    A. Drink from your canteen.
    B. Ahead at moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check
    Q. Quit.\n""")
    

    thereby eliminating the need for a seperate print().

  2. You can eliminate the need for a Done variable by using an infinite loop

    while True:
    

    and replacing every Done = True with break. This will also eliminate the need for using and not done in some of the conditions.

  3. Instead of doing stuff like

    camelFatigue *= 0
    thirst *= 0
    

    You can use

    camelFatigue = thirst = 0
    
  4. You have

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    

    You should also have an else printing an error message in case the user enters something invalid. Like so:

    if userInput.lower() == "q":
        # ...
    elif userInput.lower() == "e":
        # ...
    elif userInput.lower() == "d":
        # ...
    elif userInput.lower() == "c":
        # ...
    elif userInput.lower() == "b":
        # ...
    elif userInput.lower() == "a":
        # ...
    else:
        print("Invalid input; Try again") # Print error message
    
Source Link
Spikatrix
  • 1k
  • 1
  • 9
  • 21
Loading