Python Forum
Ways to check if the variable works.
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ways to check if the variable works.
#1
Hi this might be a obvious answer but I cant get the random number to display when i put my name as ranNum , This is kind of a dev key to see if the random number works, I know I could just put print (ranNum) but I would like it in the python program. Thanks.
import random
print("Hello \nPlease enter your name")
myName = input()
ranNum = random.randint(1, 100)


if myName == ranNum:
    print (ranNum)
else:
    print ()

I got it working I am really stupid

Just add a variable called devkey = 'ranNum'
then:
if myName == devkey:
print (ranNum)
else:
print ()
Reply


Messages In This Thread
Ways to check if the variable works. - by AlwaysNew - May-02-2017, 07:48 PM
RE: Ways to check if the variable works. - by buran - May-02-2017, 08:20 PM
RE: Ways to check if the variable works. - by wavic - May-04-2017, 05:51 AM

Forum Jump:

User Panel Messages

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