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


Messages In This Thread
Beginner Higher Lower Game - by wallytan - Sep-29-2022, 03:14 AM
RE: Beginner Higher Lower Game - by menator01 - Sep-29-2022, 06:58 AM
RE: Beginner Higher Lower Game - by deanhystad - Sep-29-2022, 05:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to apply function lower() to the list? Toltimtixma 2 821 Feb-10-2023, 05:15 PM
Last Post: Toltimtixma
  Regex higher IR library DreamingInsanity 6 2,290 Jun-06-2022, 02:37 PM
Last Post: DreamingInsanity
Question Beginner Boolean question [Guessing game] TKB 4 2,402 Mar-22-2022, 05:34 PM
Last Post: deanhystad
  Tic-Tac game (Beginner's coding) Shahmadhur13 5 3,212 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,834 Jun-18-2020, 04:59 PM
Last Post: QTPi
  Need help with rpsls game(Beginner corner) Bulxy88 1 1,701 Jun-01-2020, 02:42 PM
Last Post: pyzyx3qwerty
  lower() applied at in operator Beerforfree 3 2,375 Mar-22-2020, 11:51 AM
Last Post: ndc85430
  How to change a dataframe column to lower case zhujp98 5 6,413 Oct-29-2019, 06:42 PM
Last Post: zhujp98
  finding the next higher representable floating point value Skaperen 0 1,970 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  the next higher character Skaperen 13 4,981 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