Skip to content

Commit

Permalink
Merge pull request YearOfProgramming#186 from returnlove/master
Browse files Browse the repository at this point in the history
challenge_0 in python
  • Loading branch information
Remillardj committed Jan 4, 2017
2 parents 0fdc121 + ec268e2 commit 851053a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions challenge_0/python/returnlove/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello world.

run:
python helloworld.py
1 change: 1 addition & 0 deletions challenge_0/python/returnlove/src/helloworld.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello World!")
6 changes: 6 additions & 0 deletions challenge_1/python/returnlove/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Solution to reverse a string

Run:

python reverse_a_string.py
type input string on the console and enter
19 changes: 19 additions & 0 deletions challenge_1/python/returnlove/src/reverse_a_string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# read input string from user
input_string = raw_input("enter any string")

# solution 1
# create a variable to store the reversed string
reversed_string = ""

# loop through the input in reverse order and append each letter
for l in xrange(len(input_string)-1, -1, -1):
reversed_string += str(input_string[l])

print('Solution 1: ',reversed_string)


# solutin 2
print('Solution 2: ',''.join(reversed(input_string)))

# solution 3
print('Solution 3: ',input_string[::-1])

0 comments on commit 851053a

Please sign in to comment.