Discuss List comprehensions in the Python Programming forum on Dev Shed. List comprehensions Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
Time spent in forums: 1 Month 2 Weeks 3 Days 14 h 10 m 30 sec
Reputation Power: 383
It works. Note that in python3 input returns a string, so str(input()) is a bit wasteful. Now, if you're trying to run this as a module and you want to see the result you'd need to explicitly print result of the expression.
print([chars.upper() for chars in input_string])
Python 3.2.3 (default, Sep 10 2012, 18:14:40)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> input_string = str(input(' your letters here: '))
your letters here: a;kjas;lkf
>>> [chars.upper() for chars in input_string]
['A', ';', 'K', 'J', 'A', 'S', ';', 'L', 'K', 'F']
[code]Code tags[/code] are essential for python code!