About 50 results
Open links in new tab
  1. python - How do I put a variable’s value inside a string (interpolate ...

    How do I put a variable’s value inside a string (interpolate it into the string)? Asked 15 years, 9 months ago Modified 1 year, 11 months ago Viewed 1.5m times

  2. python - Using a string variable as a variable name - Stack Overflow

    Jul 19, 2012 · I have a variable with a string assigned to it and I want to define a new variable based on that string.

  3. python - Insert variable values into a string - Stack Overflow

    Closed 5 years ago. I want to introduce a variable [i] into a string in Python. For example look at the following script. I just want to be able to give a name to the image, for example geo[0].tif ... to …

  4. python - How to insert string into a string as a variable ... - Stack ...

    This is a built in method for all strings in python, which allow you to easily replace the placehoder {} within python strings, with any variables. Unlike solution number 3 above, this format () method …

  5. Initialize a string variable in Python: "" or None? - Stack Overflow

    Hence, if your class copes with empty strings and you like it as a default value, use "". If your class needs to check if the variable was set at all, use None. Notice that it doesn't matter if your variable is …

  6. How to check if the string is empty in Python? - Stack Overflow

    Does Python have something like an empty string variable where you can do: if myString == string.empty: Regardless, what's the most elegant way to check for empty string values? I find hard …

  7. How can I print variable and string on same line in Python?

    I am using python to work out how many children would be born in 5 years if a child was born every 7 seconds. The problem is on my last line. How do I get a variable to work when I'm printing text ...

  8. python - How can I use f-string with a variable, not with a string ...

    print(user_input.format(element=value)) String formatting placeholders that use names (such as {element}) are not variables. You assign a value for each name in the keyword arguments of the …

  9. Convert string to variable name in python - Stack Overflow

    Convert string to variable name in python [duplicate] Asked 12 years, 4 months ago Modified 5 years, 8 months ago Viewed 457k times

  10. How to get the value of a variable given its name in a string?

    Oct 23, 2015 · For simplicity this is a stripped down version of what I want to do: def foo(a): # I want to print the value of the variable # the name of which is contained in a I know how to do this in ...