L
L
LoLwytN2020-05-21 12:51:58
Python
LoLwytN, 2020-05-21 12:51:58

TypeError: '>' not supported between instances of 'int' and 'generator'?

In general, I'm trying to compare the whatsDate variable with this function cal.itermonthdays(2020, nowMonth.month)
and this error comes out: TypeError: '>' not supported between instances of 'int' and 'generator' ?

def makelistDate():
    cal = calendar.Calendar()
    nowMonth = datetime.datetime.now()

    for whatsDate in cal.itermonthdays(2020, nowMonth.month):
         print(whatsDate, end='\t')

    whatsDate = int(input('\n' '...'))
    if whatsDate > cal.itermonthdays(2020, nowMonth.month):
        print('Правильную дату введи!')
    else:
        print(whatsDate)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deleting Account, 2020-05-21
@LoLwytN

Well, what did you want. Compare number and generator, seriously? Learn the basics, then ask questions. And I don't really understand you. If you want to check if there is a value in an iterator, then use in.
Example:

if whatsDate not in cal.itermonthdays(2020, nowMonth.month):
         print('Правильную дату введи!')

That is if I understand you correctly.

A
a, 2020-05-21
@MZOK

The error says that you cannot compare "generator" with "int", translate cal.itermonthdays(2020, nowMonth.month) into int.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question