← Projects

reverse a string using an init method

829872cf405054627ae8d2f166706b4da944a6db · ovidiucs · May 21, 2015 23:52

+10 · 1 file changed

  • 02.Reverse-A-String.py +10 −0
diff --git a/02.Reverse-A-String.py b/02.Reverse-A-String.py
new file mode 100644
index 0000000..3c39d6b
--- /dev/null
+++ b/02.Reverse-A-String.py
@@ -0,0 +1,10 @@
+__author__ = 'ovidiucs'
+
+class Reverse:
+    def __init__(self,string):
+        self.string=string[::-1]
+
+# at class instantiation
+x = Reverse("LeGrand")
+
+print x.string
\ No newline at end of file