পাইথনে স্ট্রিং থেকে আলাদা করে কোনো কিছু যদি আলাদাভাবে প্রিন্ট করতে হয় যেমনঃ বড় হাতের অক্ষর একটি স্ট্রিংয়ে আবার ছোট হাতের অক্ষর আরো একটি স্ট্রিংয়ে রেখে প্রিন্ট করতে হয় তাহলে কিভাবে করবো?

asked 06 Jan, 16:32

shishir's gravatar image

shishir
375

edited 06 Jan, 16:48

Mosharraf%20Hosain's gravatar image

Mosharraf Hosain ♦
16618


mixedString = 'ThisISMiXedAndHaveNumbersLike2AND3'
upper = ''
lower = ''

#Iterate through individual characters in the string
for ch in mixedString:
    # Check if its an alphabet not digit or something else
    if ch.isalpha():
        # Check if its an upper case character
        # If it is, keep it in *upper* string variable
        if ch.isupper():
            upper += ch

        # Otherwise its lower case character
        # Keep it in *lower* string variable
        else:
            lower += ch

print upper
print lower
permanent link

answered 06 Jan, 18:26

Ashfaqur%20Rahman's gravatar image

Ashfaqur Rahman
5099

thanks bhai :)

(07 Jan, 14:50) shishir
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×33

question asked: 06 Jan, 16:32

question was seen: 63 times

last updated: 07 Jan, 14:50