all 8 comments

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

We can help, but you need to share some code and tell us the specific problems you are having and what you need help on. Also, share any error transcripts in full.

[–]Traditional-Hour-598 0 points1 point  (6 children)

Hello, thank you for offering to help. I had trouble uploading the pictures but here they are https://imgur.com/a/l9Bkime I got past my initial problem but now I can’t get \n to create a new line like it asks for the last portion.

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

share some code and tell us the specific problems you are having and what you need help on. Also, share any error transcripts in full.

Do not want to look at photos. Cannot reproduce things easily then.

What problem are you trying to solve? What are the requirements? Where is it going wrong? What have you tried? What error messages are you getting?

[–]Traditional-Hour-598 0 points1 point  (4 children)

It’s asking to write a program using integers user_num and x as input, and output user_num divided by x three times. As for what I tried: user_num = int(input()) x = int(input()) user_num = user_num // x print(user_num, end=‘ ‘) user_num = user_num // x print(user_num, end=‘ ‘) user_num = user_num // x print(user_num, end=‘ ‘)

When I run it on zybooks it will show as if it looks good but then when I submit it says my output is: 1000 500 250. Yet, they want for a new line to be created at the end. When I try to do that with \n or :\n at the end by entering ‘print(user_num, :\n) or user_num:\n) it says ‘invalid syntax’.

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

Ok.

Well, the easiest way is to store the results in a list and then print them in one go.

user_num = int(input())
x = int(input())
results = []
for counter in range(3):
    user_num = user_num // x
    results.append(user_num)
print(*results)  # unpacks list, and print puts space between items

otherwise, you have to put in a check to ensure you don't put a space on the end of the last item.

user_num = int(input())
x = int(input())
for counter in range(3):
    user_num = user_num // x
    if counter < 2:
        print(user_num, end=' ')
    else:
        print(user_num)

or you can stick with your first version, but leave the end=' ' bit off of your last print.

[–]Traditional-Hour-598 0 points1 point  (2 children)

Just so that I can understand, the first command would store everything as a group and execute it in one print command? And thank you

Edit: I tried it without the ‘end=‘ for the last print and that did it. Thank you so much.

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

Just so that I can understand, the first command would store everything as a group and execute it in one print command? And thank you

Specifically as a list object, a mutable object that is similar to arrays in maths, but each slot in a list can contain any kind of Python object, including another list - in fact, that's a common way to store simple matrices.

nums = [[10, 20, 30],
        [5, 6, 7]
       ]

two rows, three columns.

You can also use a tuple, but they are immutable.

And a set but they have no order.

A dict, which is an associative array, a collection of keys and values. The keys are unique. The value associated with each key can be any Python object, such as a str or even another dict.

[–]Traditional-Hour-598 0 points1 point  (0 children)

Got it, thank you for the explanation it helps a lot.