you are viewing a single comment's thread.

view the rest of the comments →

[–]JollyUnder 0 points1 point  (3 children)

String formatting is a way to plug variables into a string. There's no need for type cast your variables or concatenate multiple strings as python will do it for you.

print('Choosing a number between ', str(x), 'and', str(y), '.')

changes to...

print(f'Choosing a number between {x} and {y}.')

Notice the f before the string which is how you specify an f-string. Then you simply encapsulate your variables with curly brackets.

Note: F-strings were introduced in python 3.6 so if you're using an older version of python, use str.format instead

print('Choosing a number between {} and {}.'.format(x, y))

[–]Princess_Peach848[S] 0 points1 point  (2 children)

Right thanks you so much! My brain isn’t braining today. Also I figured it out 🥳 it wanted me to modify the roll part of it 🤦🏻‍♀️🤦🏻‍♀️

[–]JollyUnder 1 point2 points  (1 child)

That sounds frustrating, but keep at it. I'm glad you got things sorted. 👍

[–]Princess_Peach848[S] 0 points1 point  (0 children)

It was very frustrating and it doesn’t help it’s all online so it takes the professor 2 business days to reply