Skip to content

Commit

Permalink
Merge pull request keon#42 from ankit167/Fix_reverse_words
Browse files Browse the repository at this point in the history
Fixed checks in 'if' conditions
  • Loading branch information
keon authored Apr 27, 2017
2 parents 0d36285 + d5af367 commit de89258
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions string/reverse_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def reverse_words(string):
start = None
for i in range(n):
if arr[i] == " ":
if start:
if start is not None:
reverse(arr, start, i-1)
start = None
elif i == n-1:
if start:
if start is not None:
reverse(arr, start, i)
else:
if not start:
if start is None:
start = i
return "".join(arr)

Expand Down

0 comments on commit de89258

Please sign in to comment.