wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let c = 1; let c = 100; | let c = 1; c = 100; | Duplicate declaration. | JavaScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
List(24,49,25) | List(24,49,25) | Correct. | Scala |
assert index > 2 | assert index > 2 | Correct. | Python |
6num = 10 | num6 = 10 | Variable cannot start with digit. | Python |
age: test
id: hello, | age: test
id: hello | Remove comma. | YAML |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
if z = 14: | if z == 14: | Use == for comparison. | Python |
if data = 30 | if data == 30 | Use ==. | Go |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if [ $item = 38 ]; then | if [ "$item" = 38 ]; then | Quote variable. | Shell |
val bar: Int = 'info' | val bar: String = 'info' | Fix type. | Kotlin |
let item: Int = 'data' | let item: String = 'data' | Fix type. | Swift |
<person age=87> | <person age="87"> | Quote attribute. | XML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
while y > 20
y -= 1 | while y > 20:
y -= 1 | Colon missing after while. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
with open('config.json') as f:
data = f.read() | with open('config.json') as f:
data = f.read() | Correct. | Python |
String foo = 'output'; | String foo = "output"; | Double quotes. | Java |
x = 24 | x=24 | No spaces. | Shell |
$items[75] | if ($items.Count -gt 75) {{ $items[75] }} | Check bounds. | PowerShell |
WHERE email = '24' | WHERE email = 24 | Don't quote integer. | SQL |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
cin >> data
cout << data; | cin >> data;
cout << data; | Add semicolon. | C++ |
compute | compute() | Add parentheses. | Swift |
my @arr = (38,25,60); | my @arr = (38,25,60); | Correct. | Perl |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let v=vec![69,37,53]; let first=&v[0]; v.push(88); | let mut v=vec![69,37,53]; let first=v[0]; v.push(88); | Copy instead of reference. | Rust |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
int[] arr = new int[84];
arr[84] = 5; | int[] arr = new int[84];
if (84 < arr.length) arr[84] = 5; | Check bounds. | Java |
let bar = 'value' | let bar = "value" | Double quotes. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
[99, 52, 67 | [99, 52, 67] | Close bracket. | Python |
println('test') | println("test") | Double quotes. | Scala |
<input type='text' value='info'> | <input type='text' value='info' name='age'> | Add name attribute. | HTML |
h1 {{ font-size:59px color:red; }} | h1 {{ font-size:59px; color:red; }} | Add semicolon. | CSS |
$arr[59] = 5; | if (isset($arr[59])) $arr[59] = 5; | Check existence. | PHP |
val c = 'info' | val c = "info" | Double quotes. | Kotlin |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
int items[5]; items[5]=5; | int items[5]; if(5<5){{}} else items[5]=5; | Bounds check. | C++ |
UPDATE users SET status='value' WHERE email=99 | UPDATE users SET status='value' WHERE email=99; | Add semicolon. | SQL |
values[84] | if (values.indices.contains(84)) values[84] | Check index. | Kotlin |
'77' + 78 | 77 + 78 | Avoid string coercion. | JavaScript |
if (z = 99) | if (z == 99) | Use ==. | R |
let str = String::from("world"); let borrow=&str; str.push_str("!"); | let mut str = String::from("world"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if a > 96
puts 'result' | if a > 96
puts 'result'
end | Add 'end'. | Ruby |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function baz(): void {{ return 15; }} | function baz(): number {{ return 15; }} | Return type mismatch. | TypeScript |
{{"name":"world" "name":62}} | {{"name":"world", "name":62}} | Add comma. | JSON |
if a = 30 | if a == 30 | Use ==. | MATLAB |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
print('output') | print('output') | Correct. | R |
INSERT INTO products VALUES ('hello',70) | INSERT INTO products (age, role) VALUES ('hello',70); | Specify columns. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
for i=1,8 do print(i) end | for i=1,8 do print(i) end | Correct. | Lua |
if a = 29 {{}} | if a == 29 {{}} | Use ==. | Swift |
<br></br> | <br> | Self-closing. | HTML |
def handle():
print('test') | def handle():
print('test') | Indent function body. | Python |
var x int = 'message' | var x string = 'message' | Type mismatch. | Go |
'output' + 69 | 'output' + 69.to_s | Convert int. | Ruby |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (val = 94) | if (val == 94) | Use ==. | Scala |
<person><name>data</name><age>64</age></person | <person><name>data</name><age>64</age></person> | Add closing >. | XML |
let str = String::from("data"); let borrow=&str; str.push_str("!"); | let mut str = String::from("data"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x = 42; | var x = 42; | Correct. | Dart |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
item = info | item = 'info' | Quote strings. | Python |
SELECT * FROM users WHRE status=2; | SELECT * FROM users WHERE status=2; | Fix WHERE. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(3); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(3); | Correct. | Node.js |
for (result in data) | for (result of data) | for...in iterates keys. | JavaScript |
class Product {{ int z; }}; | class Product {{ public: int z; }}; | Make public. | C++ |
[x*x for x in items if x > 62] | [x*x for x in items if x > 62] | Correct list comprehension. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
{{'title':34, 'name' 93}} | {{'title':34, 'name':93}} | Colon missing. | Python |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
z == '93' | z === 93 | Use strict equality. | JavaScript |
if (num = 2) {} | if (num == 2) {} | Use ==. | Dart |
if bar = 97 | if bar == 97 | Use ==. | Go |
<input type='text' value='hello'> | <input type='text' value='hello' name='status'> | Add name attribute. | HTML |
if y = 43: | if y == 43: | Use == for comparison. | Python |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
let foo = 49; foo += 1; | let mut foo = 49; foo += 1; | Need mut to modify. | Rust |
val a = 18; a = 84 | var a = 18; a = 84 | Use var for reassignment. | Scala |
var result int = 'hello' | var result string = 'hello' | Type mismatch. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
function baz() {{ echo 'message'; }} | function baz() {{ echo 'message'; }} | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.