Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Improvements?
#4
You also do not need to specify 'str' in conjunction with the input statement, as 'input' by default, will create a string.

so this:
sentence = str(input("Enter a sentence without punctuation: ")).lower()
is the same as:
sentence = input("Enter a sentence without punctuation: ").lower()
You only need to prepend when you want something other than a string. For example, to expect an integer from the user:
answer = int(input("Enter an integer: ")
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
Improvements? - by tahmid909 - Nov-14-2016, 06:51 PM
RE: Improvements? - by nilamo - Nov-14-2016, 08:36 PM
RE: Improvements? - by buran - Nov-14-2016, 09:22 PM
RE: Improvements? - by sparkz_alot - Nov-14-2016, 09:26 PM

Forum Jump:

User Panel Messages

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