Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text Based Game
#3
I inserted my prompt text with spacing as needed. Since this type of question requires multiple lines of code without a space between lines I removed the last else statement from the algorithm.

I tested it fully with wrong answers on the first thru the forth iteration and this is my final output, fully tested and working. Only needed minor adjustments based on my requirements.

This is q2a, the first of seven segments to answer without further prompt, line after line without any blank spacing between lines of code. For multi segmented lines of output, I have to create a code snippet like this in three slightly different variations based on if the segment is the very first segment, a mid segment or the final segment.

    for guess in range(4):
        q2a = input('Construct the minimal BOILER PLATE HTML Template answer NOW: \n\n')
        if q2a == '<!DOCTYPE html>':
            break
        if guess == 1:                  #if user guesses wrong answer on the second try, a hint is provided
            print('')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('HINT: This line of code requires the HTML5 tag, no indent, then hit the ENTER KEY and code the next line')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('')
        elif guess == 3:                #if user guesses wrong answer on the forth try, the answer is provided
            print('')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('ANSWER:     <!DOCTYPE html>     Type in this answer NOW, then hit the ENTER KEY and code the next line')
            print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@')
            print('')
            q2a = input()               #the cursor is waiting for user to type in the answer given to them
        else:
            print(wrong)                #a global wrong text message is printed to screen
#    else:
#        print('Correct answer.')       #remove or move this based on single or multiple answer questions, NO MULTI
    q2b()
Thank you Ichabod801 for the awesome code, does this forum give me the option to mark as DONE or give you a rating?
Reply


Messages In This Thread
Text Based Game - by DuaneJack - Aug-14-2018, 01:35 AM
RE: Text Based Game - by ichabod801 - Aug-14-2018, 12:59 PM
RE: Text Based Game - by DuaneJack - Aug-15-2018, 04:57 AM
RE: Text Based Game - by ichabod801 - Aug-15-2018, 12:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Game - Choice Based theor 4 8,507 May-22-2024, 01:17 PM
Last Post: alanbriggs
  Text-Based RPG - After selecting correct decision it also prints others code KimJiwoo1 1 1,775 Apr-26-2023, 08:30 PM
Last Post: deanhystad
  Complete beginnner making a text based adventure Mishmaccles 2 3,568 Jul-07-2021, 05:00 PM
Last Post: BashBedlam
  Adding an inventory and a combat system to a text based adventure game detkitten 2 9,856 Dec-17-2019, 03:40 AM
Last Post: detkitten
  Using classes for room movement (text game) Lawr3y 3 8,400 Aug-20-2019, 12:40 AM
Last Post: Lawr3y
  Text Game Testing/Dev PKMindBlow 21 14,463 Feb-05-2018, 11:04 PM
Last Post: PKMindBlow

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020