0
Please help me revise the code. The purpose is to remove all vowels from text but the loop just do once then stop. Plz show erro
11 Respuestas
+ 1
Your return statement is in the for loop put it in the function indentation instead
+ 1
In Python 2 print is a statement instead of a function e.g.
print 4
Also the Python 3 range is xrange in Python 2 (this is optional but is better performance wise)
+ 1
Yes Python 2 and 3 ranges work differently. In Python 2 range returns a list, xrange and Python 3 range return something called a generator object which is much faster with big ranges (e.g. 1 -> 100000), they return a number every iteration rather than return a whole list at the start
+ 1
https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement
0
Many thanks TurtleShell . By the way, could you show me why the revised code working in python 3 but not python 2?
0
Thanks TurtleShell! But I don't understand 'xrange'. Does it imply that range in py3 different from py2?
0
Thanks TurtleShell for your very promptly and clearly support!
0
https://code.sololearn.com/c22ByGvQRLg9/?ref=app
no need to use ranges or complicated statements
0
thanks Markus Kaleton ! my code seems diffuse coz I'm not familiar with 'pass'. Could you help me understand it?
0
many thanks Markus Kaleton ! I got it!