Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beginner Higher Lower Game
#1
I am trying this beginner project of Higher Lower game. I pretty much got already 99% of the game's logic. The only thing I couldn't figure out is to keep the logo and vs stay in place while choice B keeps replacing choice A, then B picks randomly again.

Meaning:

"""LOGO""" (I want this to stay and not move/change)

Random pick here (while this would keep changing)

"""VS""" (I want this to stay and not move/change)

Random pick here (while this would keep changing)


Thanks in advanced.


def play_again():
  
  #Choice A
  a_compare = random.choice(data)
  a_followers = a_compare['follower_count']
  #########################################
  
  #Choice B
  b_compare = random.choice(data)
  b_followers = b_compare['follower_count']
  #########################################
  
  score = 0
  correct_answer = True
  # print(logo)
  # print(a_compare)
  # print(vs)
  # print(b_compare)
  while correct_answer:
    print(logo)
    print(a_compare)
    print(vs)
    print(b_compare)
    guess = input("Who has more followers. A or B: ").lower()
    if guess == 'a':
      if a_followers > b_followers:
        
        #Keep track of player's score.
        score += 1
        print(f"Correct! Your current score is {score}\n")
        #########################################
        
        #This code is for B to keep replacing A as long as guess is correct.
        a_compare = b_compare
        a_followers = b_followers
        ###################################
        
        #This code is for B to keep randomly choosing as long as guess is right.
        b_compare = random.choice(data)
        b_followers = b_compare['follower_count']
        ###################################
      else:
        correct_answer = False
        print(f"Sorry, that's wrong. Your final score is {score}")
        keep_playing()
        
    if guess == 'b':
      if b_followers > a_followers:
        
        #Keep track of player's score.
        score += 1
        print(f"Correct! Your current score is {score}\n")
        #########################################
        
        #This code is for B to keep replacing A as long as guess is correct.
        a_compare = b_compare
        a_followers = b_followers
        ###################################
        
        #This code is for B to keep randomly choosing as long as guess is right.
        b_compare = random.choice(data)
        b_followers = b_compare['follower_count']
        ###################################
      else:
        correct_answer = False
        print(f"Sorry, that's wrong. Your final score is {score}")
        keep_playing()

play_again()
Reply
#2
Is this part of a bigger program?

what is a_compare['follower_count'] and b_compare['follower_count']?
where is the function keep_playing() defined?
This code will throw errors. Need more information.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
How much do you want the logo to stay in place? Doing that will be far more complicated than writing the game. It is possible, but will involve learning how to use a Python package designed for writing terminal user interfaces. It would be easier to write your game using a window based GUI toolkit like tkinter or pysimplegui.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to apply function lower() to the list? Toltimtixma 2 798 Feb-10-2023, 05:15 PM
Last Post: Toltimtixma
  Regex higher IR library DreamingInsanity 6 2,229 Jun-06-2022, 02:37 PM
Last Post: DreamingInsanity
Question Beginner Boolean question [Guessing game] TKB 4 2,351 Mar-22-2022, 05:34 PM
Last Post: deanhystad
  Tic-Tac game (Beginner's coding) Shahmadhur13 5 3,171 Aug-29-2020, 08:40 PM
Last Post: deanhystad
  Beginner Code, how to print something after a number of turns (guessing game) QTPi 4 2,762 Jun-18-2020, 04:59 PM
Last Post: QTPi
  Need help with rpsls game(Beginner corner) Bulxy88 1 1,685 Jun-01-2020, 02:42 PM
Last Post: pyzyx3qwerty
  lower() applied at in operator Beerforfree 3 2,342 Mar-22-2020, 11:51 AM
Last Post: ndc85430
  How to change a dataframe column to lower case zhujp98 5 6,361 Oct-29-2019, 06:42 PM
Last Post: zhujp98
  finding the next higher representable floating point value Skaperen 0 1,957 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  the next higher character Skaperen 13 4,883 Jun-07-2019, 01:44 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

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