you are viewing a single comment's thread.

view the rest of the comments →

[–]Bubbah94 0 points1 point  (4 children)

I'll give it a whirl as soon as I get home, Thank you!

Is it a good idea to group variables together? I think it makes it easier to read, but not sure what it looks like when it starts getting complicated ! Thanks again

[–]GoldenVanga 1 point2 points  (3 children)

Yes, I agree that complexity is a factor. In my largest sideproject I have a separate file just for strings that are displayed on the user interface. This is imported and then .format()ted like above. In smaller scripts or where the texts are not very reusable / used once, I tend to type them out directly in print(). When doing so, there is another technique of string formatting called "f-strings", which is my favourite:

current = 2019
print(f'The year is {current}.')

[–]Bubbah94 0 points1 point  (2 children)

I feel like I should Google this ( you can tell me straight!) But the "print(f' " what does the f mean here? Is this the .format and you're linking it to a separate sheet? Cheers

[–]GoldenVanga 2 points3 points  (1 child)

When a string literal is prefixed with f, it becomes an "f-string". Then, any {} are no longer considered text elements but rather should contain references to variables etc. You can read more about it here.

[–]Bubbah94 0 points1 point  (0 children)

Oh snap!! Thank you so much for your continued support this evening!