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, 8 months ago Modified 1 year, 11 months ago Viewed 1.5m times

  2. 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 …

  3. 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.

  4. 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 …

  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 do I append one string to another in Python?

    Dec 14, 2010 · For handling multiple strings in a list, see How to concatenate (join) items in a list to a single string. See How do I put a variable’s value inside a string (interpolate it into the string)? if …

  7. 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 …

  8. 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 ...

  9. 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 …

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

    Oct 23, 2015 · If it's a global variable, then you can do: >>> a = 5 >>> globals()['a'] 5 A note about the various "eval" solutions: you should be careful with eval, especially if the string you're evaluating …