Oct-27-2020, 04:59 PM
(Oct-27-2020, 12:13 PM)jps2020 Wrote: I'm sorry to say it doesn't work for me, and I'm not sure why.
This is my code, where I've replaced Line 5 with your suggestion, bowlofred:
temperature = (input("Insert temperature: "))
if "f" in temperature or "F" in temperature:
temperature = temperature.upper()
temperature.replace("F", "") # this is a noop because the replaced string is not captured anywhere
print(temperature)
When I run it, I'm asked to input temperature.
I input 32F.
It then prints:
32F
So there's nothing being replaced.
Hello jps,
can you try something like this:
temperature = input("Insert temperature: ") new_str = temperature.replace('F', '') new_str = new_str.replace('C', '') new_str = new_str.replace('f', '') new_str = new_str.replace('c', '') print(new_str)