[Tutor] Appropriate use of list comprehension

Manprit Singh manpritsinghece at gmail.com
Wed Jun 10 04:32:28 EDT 2020


Hi all ,

I just need to know that the way I have used to enter 3 names inside the
list , entered through keyboard, using list comprehension is syntactically
correct or not . Is there any other more efficient way to do this?
Below is the code given :

val = [input("enter name") for _ in range(3)]

val will be the list consisting those 3 names entered through keyboard.

Regards
Manprit Singh


More information about the Tutor mailing list