Resolve Issue #40: Changed more examples to use python3 syntax (#56)

This commit is contained in:
Ramit Mittal
2018-03-19 22:18:21 +05:30
committed by Aditya Bhargava
parent f9497eb344
commit 2f939182ae
4 changed files with 8 additions and 8 deletions

View File

@@ -1,13 +1,13 @@
def greet2(name): def greet2(name):
print "how are you, " + name + "?" print("how are you, ", name, "?")
def bye(): def bye():
print "ok bye!" print("ok bye!")
def greet(name): def greet(name):
print "hello, " + name + "!" print("hello, ", name, "!")
greet2(name) greet2(name)
print "getting ready to say bye..." print("getting ready to say bye...")
bye() bye()
greet("adit") greet("adit")

View File

@@ -4,4 +4,4 @@ def fact(x):
else: else:
return x * fact(x-1) return x * fact(x-1)
print fact(5) print(fact(5))

View File

@@ -4,4 +4,4 @@ def sum(arr):
total += x total += x
return total return total
print sum([1, 2, 3, 4]) print(sum([1, 2, 3, 4]))

View File

@@ -1,10 +1,10 @@
voted = {} voted = {}
def check_voter(name): def check_voter(name):
if voted.get(name): if voted.get(name):
print "kick them out!" print("kick them out!")
else: else:
voted[name] = True voted[name] = True
print "let them vote!" print("let them vote!")
check_voter("tom") check_voter("tom")
check_voter("mike") check_voter("mike")