Python Forum
print doesnt work in a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print doesnt work in a function
#2
Your code never calls luckfactorfunction(). Check indenting, I think you have an error with that.

I'm pretty sure this does not do what you think it does:
randomnumber != range(1, 776) and range(778, 1000)
A number will never equal an iterator, so randomnumber != range(1, 776) is always true.

Do not use randome.sample to get a random int in some range. Instead of this:
randomnumber = random.sample(range(1, 1000), 1)
do this:
randomnumber = random.randint(1, 999)
Can you describe what this code is supposed to do?
def luckfactorfunction():
    if randomnumber != 777:
 
        print("jackpot")
    else:
        if randomnumber != range(1, 776) and range(778, 1000):
            print("better luck next time")
 
    luckfactorfunction()
Reply


Messages In This Thread
print doesnt work in a function - by ony - Mar-10-2024, 06:51 PM
RE: print doesnt work in a function - by deanhystad - Mar-10-2024, 09:59 PM
RE: print doesnt work in a function - by Pedroski55 - Mar-11-2024, 12:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  equalto validator doesnt work robertkwild 1 1,037 Jun-02-2024, 06:16 AM
Last Post: Pedroski55
  Pydoc documentation doesnt work Cosmosso 5 7,123 Nov-25-2023, 11:17 PM
Last Post: vidito
  pip install requests doesnt work misodca 8 23,119 Jul-07-2023, 08:04 AM
Last Post: zyple
  How to print variables in function? samuelbachorik 3 1,986 Dec-31-2022, 11:12 PM
Last Post: stevendaprano
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 11,681 Dec-28-2022, 11:22 AM
Last Post: shad
  I dont know why my function won't work? MehHz2526 3 2,170 Nov-28-2022, 09:32 PM
Last Post: deanhystad
  pip install pystyle doesnt work person_probably 2 4,052 Sep-23-2022, 02:59 PM
Last Post: person_probably
  How to print the output of a defined function bshoushtarian 4 2,469 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  Why doesnt chunk generation work? LotosProgramer 1 2,630 Apr-02-2022, 08:25 AM
Last Post: deanhystad
  Why does absence of print command outputs quotes in function? Mark17 2 2,210 Jan-04-2022, 07:08 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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