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)
![Darren Jones](https://secure.gravatar.com/avatar/b38a765d0e7e41f18bfbc386fa7904ed?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Darren Jones
280 PointsQuestion regarding changing string to integer. Different method, same result?
When I done the task myself, I used the following line of code:
# Prompt the user by name and ask how many tickers they would like
number_of_tickets = int(input("Hello {}, how many tickets would you like to buy today? ".format(name)))
But I noticed the teacher chose to do it a slightly different way where he converted the string to an integer on a separate line such as:
# Prompt the user by name and ask how many tickers they would like
number_of_tickets = input("Hello {}, how many tickets would you like to buy today? ".format(name))
number_of_tickets = int(number_of_tickets)
I'm just wondering if there is any difference between the two methods and was I 'wrong' for doing it my way, as it seemed to work ok?
Thank you
TICKET_PRICE = 10
tickets_remaining = 100
#Output how many tickets are remaining
print("There are {} tickets remaining".format(tickets_remaining))
# Gather the users name and assign it to a new variable
name = input("What is your name? ")
# Prompt the user by name and ask how many tickers they would like
number_of_tickets = int(input("Hello {}, how many tickets would you like to buy today? ".format(name)))
# Calculate the price (number of tickets multiplied by the price) and assing it to a variable
cost_of_tickets = number_of_tickets * TICKET_PRICE
# Output the price to the screen
print("{} tickets will cost a total of ${}".format(number_of_tickets, cost_of_tickets))
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe end result is exactly the same, the teacher most likely broke it down into individual steps for extra clarity. You'll find that that lesson examples can often be made more compact and efficient when the focus is entirely on functionality and illustrating the concepts is not a concern.
![Darren Jones](https://secure.gravatar.com/avatar/b38a765d0e7e41f18bfbc386fa7904ed?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Darren Jones
280 PointsThanks Steven