Elo
0
Q:

how to pass in f string python

>>> name = "Eric"
>>> age = 74
>>> f"Hello, {name}. You are {age}."
'Hello, Eric. You are 74.'
19
import random
name = input("What is your name? ") #Gets needed input
value = int(input(f"Give random value, {name}: ")) # The {name} means it puts the variable name there
multiplier = random.randint(3, 6)
print("Now multiplying your value...")
complete_value = multiplier * value
print(f"Your value is... {complete_value}") # Same here with complete_value
1
>>> f"{{70 + 4}}"
'{70 + 4}'
0

New to Communities?

Join the community