0

What library do I need to use in python to have (isalpha and upper) I need them to run caesar.py

it's possible to use in pset6 cs50 2017?

I only knows: import sys import cs50

~/workspace/pset6/ $ python caesar.py 2 hello Traceback (most recent call last): File "caesar.py", line 14, in if (isalpha(string[i])): NameError: name 'isalpha' is not defined

~/workspace/pset6/ $ python caesar.py 2 hello Traceback (most recent call last): File "caesar.py", line 15, in if (upper(string[i])): NameError: name 'upper' is not defined

1 Answer 1

1

Returns: a copy of the string in upper case.

>>> string = "Hello World"
>>> print string.upper ()
HELLO WORLD

Returns: a copy of the string in lowercase.

>>> string = "Hello World"
>>> print string.lower ()
hello world

is the output from the terminal can use the same methods in the source code

Unlike in c, we can check an entire string

str = "this";  # No space & digit in this string
print str.isalpha()

str = "this is string example....wow!!!";
print str.isalpha()

When we run above program, it produces following result −

True
False
1
  • Hi Mars. But its correct to use it in this way... for i in range (i,len(string),+1): if (isalpha(string[i])): if (upper(string[i])): a = string[i] - 65 b = (a + k) % 26 c = b + 65 print(c)
    – user13767
    Commented Feb 4, 2017 at 20:11

You must log in to answer this question.