Home python Replacing the for in Range cycle on while python

Replacing the for in Range cycle on while python

Author

Date

Category

Tell me, please replace the for in Range on while ?

def what (a, b):
   RES = A.
   For i in Range (b):
     Res = Res + 1
   Return Res.

Answer 1, Authority 100%

as option

def what (a, b):
   RES = A.
   While B:
     Res = Res + 1
     B - = 1
   Return Res.

Answer 2

def what (a, b):
  RES = A.
  i = 0.
  While I & LT; B:
   res + = 1
   I + = 1
  Return Res.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions