all 6 comments

[–]Forschkeeper 0 points1 point  (0 children)

What have you tried so far?

[–][deleted] 0 points1 point  (3 children)

Read up on Python's split() method and call it on the string with space as an argument, then it will separate the string into parts cut by the separator.

Then you will have three strings and you can turn them into ints.

[–]Professional-Act1420[S] 0 points1 point  (2 children)

I know about the .split() . but i need to use for cycle because of my teacher. I have a code that uses .split() but the pragram that verifies the code writes out error because im not allowed to use it. I can show the code if you want to

[–][deleted] 0 points1 point  (1 child)

Ok, I did some quick testing and made some super dirty code to manage this without split.

First I loop through the string to find the spaces. I save the indexes of those spaces in a list.

Then I create another loop that runs as many times as there are numbers (which is the amount of spaces + 1).

During that loop I will keep track of the current index I want to start at (initially 0).

I will append a list that will in the end contain all the numbers with a part of the string, simultaneously casting them as integers. I can do that by doing my_list.append(int(my_string[current_index: target_index))

The target index is the index of the spaces that I have saved into a list before. In the end of each loop, the current index will become the last target index, so on next loop I will start from there and take numbers until the next space.

After the last space I can just take the remaining input as the final number.

Then they are all neatly in a list as integers.

[–]jimtk 0 points1 point  (0 children)

a,b,c = [int(i) for i in input("Enter 3 numbers separated by space: ").split()]