Challenge.
• Create a function named 'a' that takes a string as parameter and returns a new string after converting it to lowercase.
Character limit - less than 12 characters.
Language - Python.
Answers
Answered by
6
Language:
Python
Program:
def a(string):
if len(string)<12:
new=""
for i in string:
new+=i.lower()
return new
else:
return None
Examples of input output:
print(a("HELLO")) #outputs hello
print(a("CS")) #outputs cs
Explanation:
- str.lower() method returns a set lowercase string.
- Since strings are immutable you want change their values instead you'll have to make a new indentifier.
Attachments:
Attachments:
Answered by
2
Answer:
String s;
System.out.println ("Enter string");
s=sc.next();
int l=s.length();
for (int a=0;a<=l-1;a++)
{
char ch=s.charAt(0);
(String)d=d+ch;
}
d=d.toLowerCase();
System.out.println (d);
This one I have written in Java.
This will prove as a pathway to write in PYTHON.
Only the format needs to be changed but the processes are all same.
Similar questions