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.
#3
The problem with your code is that input will return str, while randint will yield int. You are comparing e.g. '1' with 1. Just convert the value returned from input() into int.

As a side note, input() takes an argument - the prompt to display. So, instead of 2 lines you can have call = input("Heads[1] or Tails[2]? ")
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Code giving same output no matter the input. - by buran - Dec-20-2020, 05:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem in output of a snippet code akbarza 2 417 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,239 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,091 Aug-31-2023, 05:36 PM
Last Post: deanhystad
  output provide the filename along with the input file processed. arjunaram 1 966 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,598 Mar-27-2023, 07:38 AM
Last Post: buran
  I cannot able to see output of this code ted 1 780 Feb-22-2023, 09:43 PM
Last Post: deanhystad
  Code won't break While loop or go back to the input? MrKnd94 2 992 Oct-26-2022, 10:10 AM
Last Post: Larz60+
  Help Switching between keyboard/Mic input in my code Extra 1 1,119 Aug-28-2022, 10:16 PM
Last Post: deanhystad
  why I dont get any output from this code William369 2 1,154 Jun-23-2022, 09:18 PM
Last Post: William369
  How can I organize my code according to output that I want ilknurg 1 1,201 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