Code not working | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Code not working

def main(me,friend) print("hey!") main("x","y") when I run this...I get output as hey! None.... what's the mistake?

7th Mar 2017, 7:03 PM
Sk Maidur
Sk Maidur - avatar
6 Antworten
+ 1
Put colon on the definition of main def main(me,friend): print("hey!")
7th Mar 2017, 8:36 PM
AtoMX
AtoMX - avatar
0
@Moksh: you can't recognise a function that returns nothing? @Sk: Basically, when a function doesn't have a return statement, it (implicitly) returns None. As your function doesn't have a return, it returns None.
7th Mar 2017, 9:30 PM
Amaras A
Amaras A - avatar
0
@Moksh I expected output to be x & y....& @amaras I tried using return still getting no output.... can u alter the code to get the desired result?? I want output as X & Y
7th Mar 2017, 11:51 PM
Sk Maidur
Sk Maidur - avatar
0
def main(me,friend): print(main("x","y")) return main result is ...Indentation error for return
7th Mar 2017, 11:55 PM
Sk Maidur
Sk Maidur - avatar
0
@moksh: why say print(str(me),str(friend))? does it by default not mean that arguments inside the parentheses act as variable to values assigned to them within the function??
8th Mar 2017, 8:28 AM
Sk Maidur
Sk Maidur - avatar
0
@Moksh...got it...thank u:)
8th Mar 2017, 8:55 AM
Sk Maidur
Sk Maidur - avatar