Your script:
from Bio.Seq import Seq
from Bio.Alphabet import IUPAC
my_seq = Seq("GATCG", IUPAC.unambiguous_dna)
print(len(my_seq))
for index, letter in enumerate(my_seq):
print(index, letter)
works fine for me in Python 3:
% python3 test.py
5
0 G
1 A
2 T
3 C
4 G
Reading your error messages, my guess your problem is you have a personal code file named string.py ("/home/tanuj/Desktop/biopython/scripts-test/string.py") which Python is confusing with the library string.py it wants to import:
% touch string.py
% python3 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from Bio.Seq import Seq
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/Bio/Seq.py", line 25, in <module>
from Bio._py3k import range
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/Bio/_py3k/__init__.py", line 170, in <module>
from urllib.request import urlopen, Request, urlretrieve, urlparse, urlcleanup
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 88, in <module>
import http.client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 71, in <module>
import email.parser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/feedparser.py", line 27, in <module>
from email._policybase import compat32
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/_policybase.py", line 7, in <module>
from email import header
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/header.py", line 16, in <module>
import email.quoprimime
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
ImportError: cannot import name 'ascii_letters'
%
Rename your personal string.py file to something else.