Python Forum
I need some help with my code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need some help with my code
#5
post # 2 as a function:
def get_numbers():
    str_of_numbers = input("Please enter numbers separated by spaces: ")
    list_of_numbers = [int(x) for x in str_of_numbers.split()]
    return list_of_numbers

mylist = get_numbers()
print(mylist)
Output:
Please enter numbers separated by spaces: 5 4 3 2 1 0 [5, 4, 3, 2, 1, 0]
Reply


Messages In This Thread
I need some help with my code - by SantiagoPB - Feb-27-2021, 08:19 PM
RE: I need some help with my code - by Larz60+ - Feb-28-2021, 01:23 AM
RE: I need some help with my code - by Serafim - Feb-28-2021, 02:03 PM
RE: I need some help with my code - by SantiagoPB - Feb-28-2021, 02:14 PM
RE: I need some help with my code - by Larz60+ - Feb-28-2021, 06:03 PM
RE: I need some help with my code - by naughtyCat - Aug-27-2021, 04:53 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020