dimanche 17 mai 2020

Is there any if statement condition which execute only if there is any input given by user in while loop?

I want to create a while loop which run normally until there is no input given by user. If user enter anything while running while loop then while loop first execute task based on input and then again back to normal.

while True:
try:     

   newmsg = driver.find_elements_by_class_name("_3zb-j")
   length=len(newmsg)
   msg=((newmsg[length-1].text).lower())
   if msg!=oldmsg :
       print(msg)
   newmessage=input()
   send(newmessage)
    #oldmessage=newmessage
    oldmsg=msg
except Exception as e:
    print(e)
    pass

here is my code in which while loop not execute until input is not given, but i want make it work like its continue looping if there is no input given by user if input given then first it should execute input then back to loop again.

Aucun commentaire:

Enregistrer un commentaire