Python Forum
Code giving same output no matter the input.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code giving same output no matter the input.
#1
I'm very new to programming and am trying to create a coin flipping program in which you call heads or tails, it simulates a flip, and then tells you whether you were right or wrong. My program is working fine until it comes to giving the player their result ("Win" or "loss") as it always outputs "loss". If anyone could help that would be great.

import random

print("Heads[1] or Tails[2]?\n")
call = input()

flip = random.randint(1, 2)

if flip == 1:
    print("\nIt landed on: Heads")
else:
    print("\nIt landed on: Tails")

if flip == call:
    print("\n[YOU WIN]")
else:
    print("\n[YOU LOSE]")
Reply


Messages In This Thread
Code giving same output no matter the input. - by Yort - Dec-20-2020, 12:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in output of a snippet code akbarza 2 416 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,233 Sep-24-2023, 05:03 AM
Last Post: deanhystad
Question in this code, I input Key_word, it can not find although all data was exact Help me! duchien04x4 3 1,089 Aug-31-2023, 05:36 PM
Last Post: deanhystad
  output provide the filename along with the input file processed. arjunaram 1 963 Apr-13-2023, 08:15 PM
Last Post: menator01
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,596 Mar-27-2023, 07:38 AM
Last Post: buran
  I cannot able to see output of this code ted 1 779 Feb-22-2023, 09:43 PM
Last Post: deanhystad
  Code won't break While loop or go back to the input? MrKnd94 2 986 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  Help Switching between keyboard/Mic input in my code Extra 1 1,115 Aug-28-2022, 10:16 PM
Last Post: deanhystad
  why I dont get any output from this code William369 2 1,151 Jun-23-2022, 09:18 PM
Last Post: William369
  How can I organize my code according to output that I want ilknurg 1 1,199 Mar-11-2022, 09:24 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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