Help my code not work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
9th Apr 2022, 4:01 PM
Zairy Putra
13 Answers
+ 2
the variable 'text' is not defined. remove line 11 don't call upper() in the print atatement as its not a global function. Replace each call to upper in the print statement with your up() function
9th Apr 2022, 4:03 PM
Slick
Slick - avatar
+ 3
https://code.sololearn.com/cc8r3qH3Or1R/?ref=app Once check this In ur code you have defined a function called up but you are calling upper in print statement So modify up to upper in the function name Second u written text=upper At there u no need write that line . Hope this helps you
9th Apr 2022, 4:09 PM
UNKNOWN
+ 1
Are you converting all inputs into caps?
9th Apr 2022, 4:03 PM
Faisal Issaka
Faisal Issaka - avatar
0
9th Apr 2022, 4:04 PM
Zairy Putra
0
you could also just take input like so: name = input("Enter name: ").upper()
9th Apr 2022, 4:05 PM
Slick
Slick - avatar
0
Slick ok thanks it work
9th Apr 2022, 4:06 PM
Zairy Putra
0
print("AI: What is your name?\n ") name = input("you: ") print("AI: How old are you?\n ") age = input("you: ") print("AI: What is your hobby?\n") hobby=input("you: ") def up(text): return text.upper() print("a boy named", up(name), "aged", up(age), "and their hobby is", up(hobby))
9th Apr 2022, 4:06 PM
Faisal Issaka
Faisal Issaka - avatar
0
Slick, I wanted to create a shortcut for making text uppercase
9th Apr 2022, 4:06 PM
Zairy Putra
0
You just called the function instead and pass the text And remove the upper = text line
9th Apr 2022, 4:07 PM
Faisal Issaka
Faisal Issaka - avatar
0
Yea ok
9th Apr 2022, 4:07 PM
Zairy Putra
0
print("AI: What is your name?\n ") name = input("you: ") print("AI: How old are you?\n ") age = input("you: ") print("AI: What is your hobby?\n") hobby=input("you: ") def up(text): return text.upper() print("a boy named", up(name), "aged", up(age), "and their hobby is", up(hobby))
9th Apr 2022, 7:23 PM
Andrey
Andrey - avatar
0
You defined function up() and you should call it. The expression upper=text is wrong, since there is no "text" variable assigned and this expression is not necessary.
9th Apr 2022, 7:28 PM
Andrey
Andrey - avatar
0
print("AI: What is your name?\n ") name = input("you: ") print("AI: How old are you?\n ") age = int(input("you: ")) print("AI: What is your hobby?\n") hobby=input("you: ") print("a boy named" + str(name) + "aged" + str(age), "and their hobby is", str(hobby))
11th Apr 2022, 5:58 AM
Pablo PC
Pablo PC - avatar