Python Forum
Wrong output on my code. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Wrong output on my code. (/thread-17246.html)



Wrong output on my code. - JTNA - Apr-03-2019

hello,

this code is giving me some weird output and i dont know why, I want the array to be printed out but in uppercase letters and i dont know how to make that happen correctly, as well as this error

Error:
<built-in method upper of str object at 0x7fc64e9905b0> <built-in method upper of str object at 0x7fc64e8966f8> <built-in method upper of str object at 0x7fc64e9ff5a8> <built-in method upper of str object at 0x7fc64e898af0> <built-in method upper of str object at 0x7fc64e8967a0> <built-in method upper of str object at 0x7fc64e898b30> <built-in method upper of str object at 0x7fc64e8967d8> <built-in method upper of str object at 0x7fc64e9905b0> <built-in method upper of str object at 0x7fc64e898bb0> <built-in method upper of str object at 0x7fc64e896810>
words = ["Algorithm", "Logic", "Filter", "Software", "Network", "Parameters", "Analyze", "Algorithm",
"Functionality", "Viruses"]
for word in range(len(words)):
    x = len(words)
x = ("algorithm")
y = ("logic")
z = ("filter")
a = ("software")
b = ("network")
c = ("parameters")
d = ("analyze")
e = ("algorithm")
f = ("functionallity")
g = ("viruses")
print (x.upper)
print (y.upper)
print (z.upper)
print (a.upper)
print (b.upper)
print (c.upper)
print (d.upper)
print (e.upper)
print (f.upper)
print (g.upper)



RE: Wrong output on my code. - ichabod801 - Apr-03-2019

x.upper is the method itself, which is what is getting printed. You need to call that method: x.upper(). That will give you the result, which is the string you are expecting.


RE: Wrong output on my code. - JTNA - Apr-04-2019

thanks.