Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Bastian Petersson](https://uploads.teamtreehouse.com/production/profile-photos/7653942/micro_IMG_3910.jpg)
Bastian Petersson
9,164 PointsIs there a way to make the list only accept one type?
Is there a way to make a list only accept one type like an array does in swift for example?
3 Answers
![Cooper Runstein](https://secure.gravatar.com/avatar/51849faf72df0677b8256b043707e287?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Cooper Runstein
11,850 PointsPython is a dynamically typed language, this sort of functionality doesn't exist in dynamic languages. You can check and make sure your list is all of the type you wanted, but you can't enforce it as, say, a list of integers.
![Jared Mollenkamp](https://secure.gravatar.com/avatar/8d1c754d91ce8edd378c1fa1716ec2da?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jared Mollenkamp
2,337 PointsYou could take your input ant convert it into an intager using int("7") and use the try command for if someone puts in a letter
![Sergio Andrés Herrera Velásquez](https://uploads.teamtreehouse.com/production/profile-photos/11871598/micro_favicon-colors.webp)
Sergio Andrés Herrera Velásquez
Python Development Techdegree Graduate 8,735 Pointsyou can import from the typing module the List, it won't change the functioning or coerce the type ,but would allow you to type hint it to other developers or your future self , mostly used for documentation purposes as shown below
from typing import List def sum_integers(numbers: List[int]) -> int: total = 0 for number in numbers: total += number return total
Usage:
integers: List[int] = [1, 2, 3, 4, 5] result = sum_integers(integers) print(result) # Output: 15
Bastian Petersson
9,164 PointsBastian Petersson
9,164 Pointscool, thanks