-3

I'm wondering why my code is not calling/running the function:

    TA = input('Would you like to throw again? (Y for yes and N for no) ')
if TA == ('Y') or ('y') is True:
    classMain()    
else:
    print('Goodybye!')

This is what I'm using to call the function, and this is the function itself:

DI = input('\nHow many sides are on your dice? ')

def classMain():
    global DI
    DI
    while DI.isdigit() is False:
        DI = input('\nPlease enter a real number: ')
        continue
        break 

So how can i Call the function (Function is before the first bit)?

The difference between the one you marked as a duplicate and mine, is that the function is not running which in this case is classMain().

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
Prince Dinar
  • 141
  • 1
  • 2
  • 8
  • The duplicate question shows how to achieve what you need, and [this question](http://stackoverflow.com/q/15112125/1258041) explains the kind of error you have in your code. – Lev Levitsky Jun 16 '14 at 22:03

1 Answers1

1

I imagine your trouble is in your expectation of how if TA == ('Y') or ('y') is True: behaves. It does not check if TA is either of Y or y. Instead, it checks if TA == 'Y', then checks if 'y' is True, which will never be true.

If you want to test multiple valid conditions for a variable use in like so:

if TA in ('y', 'Y'):

Of preferably, use .lower():

if TA.lower() == 'y':
g.d.d.c
  • 46,865
  • 9
  • 101
  • 111
  • Thanks that makes complete sense :) , but the function is still not running so I'm not sure what to do. – Prince Dinar Jun 16 '14 at 22:05
  • 1
    @PrinceDinar Based on your questions so far, I'd suggest you run through [the tutorial](https://docs.python.org/3/tutorial/) – jonrsharpe Jun 16 '14 at 22:39