Mar-25-2023, 05:35 AM
haven't programmed in years
thought i would try python, wrote a script that was failing
shorten the code to just the section that I think is giving the problem
the problem being that the RETURN is not returning how/what I think it should
have researched but can't see my error
think that the RETURN should be returning values for heads_count, tails_count, x, z but it's not
thought i would try python, wrote a script that was failing
shorten the code to just the section that I think is giving the problem
the problem being that the RETURN is not returning how/what I think it should
have researched but can't see my error
think that the RETURN should be returning values for heads_count, tails_count, x, z but it's not
import random x = 0 x = int(x) y = 0 y = int(y) z = "" z = str(z) heads_count = 0 tails_count = 0 heads_count = int(heads_count) tails_count = int(tails_count) def count(heads_count, tails_count, x): heads_count = 0 tails_count = 0 print("in the count function") print(f" x is {x}") while x < 10: options = ["heads","tails"] result = random.choice(options) if result == "heads": heads_count += 1 else: tails_count += 1 x += 1 print(f"heads: {heads_count} tails: {tails_count} flips {x}") print(f"heads: {type(heads_count)}") print(f" flips is {x} before leaving count function") z = input("return something?!?! : ") return (heads_count, tails_count, x, z) def main(): print(f"heads: {heads_count} tails {tails_count} flips {x}") print(f" x is {x}") print("in the main function") count(heads_count, tails_count, x) print("back in the main function? WHY is THIS not returning as I THINK?!!??") print(f"heads: {heads_count} tails {tails_count} flips {x}") print(f"heads: {type(heads_count)}") print(f"z: {type(z)}") print(f"your input was: {z}") main()thanks for any help