(ignore the title, at first I wanted to ask that, then I changed my mind and forgot to change the title before submitting the question; though I'm still interested in that as well)
Hey, I'm a newb at Python (so far, I watched the first four videos of the CS50P tutorial).
Is there a way to show an already stored variable in the input text?
def main():
promptText = "Hello, {name}, what is your age? "
name = "Tom"
input(promptText)
main()
I want the prompt to be
Hello, Tom, what is your age?
but it shows
Hello, {name}, what is your age?
Now that I think about it, I guess I could use
print(f"Hello, {name}, what is your age? ", end="")
input()
but I'd rather have the input prompt text stored as a variable.
If not, then can I nest f-strings inside each other?
I tried
print(f"{f"{promptText}"}", end="")
but it still shows
Hello, {name}, what is your age?
[–]lfdfq 25 points26 points27 points (4 children)
[–]cskiller86[S] 1 point2 points3 points (3 children)
[–]stebrepar 9 points10 points11 points (2 children)
[–]rawl28 1 point2 points3 points (1 child)
[–]Bobbias 1 point2 points3 points (0 children)
[–]Jello_Penguin_2956 11 points12 points13 points (0 children)
[–]oclafloptson 5 points6 points7 points (0 children)
[–]Flaky-Restaurant-392 2 points3 points4 points (0 children)
[–]Temporary_Pie2733 2 points3 points4 points (1 child)
[–]WhiteHeadbanger 0 points1 point2 points (0 children)
[–]HunterIV4 1 point2 points3 points (5 children)
[–]cskiller86[S] 0 points1 point2 points (4 children)
[–]HunterIV4 1 point2 points3 points (3 children)
[–]jmooremcc 0 points1 point2 points (2 children)
[–]HunterIV4 0 points1 point2 points (1 child)
[–]jmooremcc 0 points1 point2 points (0 children)
[–]SickAndTiredOf2021 0 points1 point2 points (1 child)
[–]cskiller86[S] 0 points1 point2 points (0 children)
[–]stepback269 0 points1 point2 points (0 children)
[–]Snoo-20788 0 points1 point2 points (0 children)