Python Forum
string function doesn't work in script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string function doesn't work in script
#1
I don't know if this has been posted before, but when I run the string function in interactive, it works fine, but when it comes to script it doesn't work. Here is my code:
print(str(24))
Why is that?
Reply
#2
How is it not working? What do you mean by "when it comes to script it doesn't work"?

There is no need to use the explicit str() function. Print automatically does the conversion for you.
ClockPillow likes this post
Reply
#3
(Jul-13-2021, 02:08 PM)deanhystad Wrote: How is it not working? What do you mean by "when it comes to script it doesn't work"?

There is no need to use the explicit str() function. Print automatically does the conversion for you.

Yeah you're right. I was confused as there were no quotations over the number to indicate that it was a string. Thank you.
Reply
#4
Any quotes surrounding a string is a feature of your development environment, not Python. Remember that what you see printed is only a representation of the thing, not the thing itself, and that the representation is just somebody's idea of the best representation.
ClockPillow likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 287 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 928 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,772 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 882 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  I dont know why my function won't work? MehHz2526 3 1,193 Nov-28-2022, 09:32 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 1,704 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,178 May-30-2022, 03:31 PM
Last Post: bowlofred
  Convert a string to a function mikepy 8 2,501 May-13-2022, 07:28 PM
Last Post: mikepy
  Make my py script work only on 1 compter tomtom 14 3,816 Feb-20-2022, 06:19 PM
Last Post: DPaul
  readline.parse_and_bind() does not work in start-up script of Python interpreter zzzhhh 0 1,518 Jan-18-2022, 11:05 AM
Last Post: zzzhhh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020