You need to add some debug code and see what this call returns:
feedparser.parse("https://" + U + ":" + P + "@mail.google.com/gmail/feed/atom")["feed"]
It's clearly something that does not contain a "fullcount" item. You might want to do something like this:
feed = feedparser.parse("https://{}:{}@mail.google.com/gmail/feed/atom".format(U, P))
try:
B = int(feed["feed"]["fullcount"])
except KeyError:
# handle the error
continue # you might want to sleep or put the following code in the else block
That way you can deal with the error (you might want to catch ValueError
too, in case int()
fails because of an invalid value) without it blowing up your script.