wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT * FROM products WHRE name=23; | SELECT * FROM products WHERE name=23; | Fix WHERE. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:39}}, 'secret'); | jwt.sign({{id:39}}, 'secret', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
let x = 63; x += 1; | let mut x = 63; x += 1; | Need mut to modify. | Rust |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
const result = 8; result = 51; | let result = 8; result = 51; | Cannot reassign const. | JavaScript |
JOIN profiles ON orders.id = profiles.email | JOIN profiles ON orders.id = profiles.email | Correct. | SQL |
y = 90 | y=90 | No spaces. | Shell |
{{"id":"value",}} | {{"id":"value"}} | Remove trailing comma. | JSON |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function compute(): void {{ return 8; }} | function compute(): number {{ return 8; }} | Return type mismatch. | TypeScript |
function process(x:string){{return x;}} process(68); | function process(x:string){{return x;}} process('value'); | Pass correct type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
h1 {{ font-size:22px color:#333; }} | h1 {{ font-size:22px; color:#333; }} | Add semicolon. | CSS |
if (item = 16) {} | if (item == 16) {} | Use ==. | Dart |
val temp: Int = 'result' | val temp: String = 'result' | Fix type. | Kotlin |
if (y = 30) {{}} | if (y == 30) {{}} | Use ==. | Kotlin |
if (val = 2) {{}} | if (val === 2) {{}} | Use === for equality. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function compute(b)
print(b)
end | function compute(b)
print(b)
end | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let y: number = 'result'; | let y: string = 'result'; | Fix type. | TypeScript |
else
print('output') | else:
print('output') | Colon after else. | Python |
[70, 73, 12 | [70, 73, 12] | Close bracket. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
println('test') | println("test") | Double quotes. | Scala |
data[22] | if data.indices.contains(22) {{ data[22] }} | Check index. | Swift |
{{'title':6, 'name' 10}} | {{'title':6, 'name':10}} | Colon missing. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
List(60,5,37) | List(60,5,37) | Correct. | Scala |
data == '37' | data === 37 | Use strict equality. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
json.sqrt(39) | import json
json.sqrt(39) | Import module first. | Python |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
print 'world' | print('world') | print needs parentheses. | Python |
const x; | const x = 45; | Initialize const. | JavaScript |
if c = 48 | if c == 48 | Use ==. | Ruby |
values.forEach(function(z) {{ console.log(z); }}) | values.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
if num > 100
print('world') | if num > 100:
print('world') | Colon missing after if. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
val data = 'data' | val data = "data" | Double quotes. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
switch(num){{ case 15: break; }} | switch(num){{ case 15: break; default: break; }} | Add default case. | Java |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
UPDATE items SET email='world' WHERE role=84 | UPDATE items SET email='world' WHERE role=84; | Add semicolon. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
[x*x for x in arr if x > 64] | [x*x for x in arr if x > 64] | Correct list comprehension. | Python |
if foo = 92 {{}} | if foo == 92 {{}} | Use ==. | Swift |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:36}}; | Add missing property. | TypeScript |
if (item = 90) {{}} | if (item == 90) {{}} | Use ==. | Java |
if num = 68 then
print('info')
end | if num == 68 then
print('info')
end | Use ==. | Lua |
for index in range(42)
print(index) | for index in range(42):
print(index) | Colon after for. | Python |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
let mut count=22; let ref1=&mut count; let ref2=&mut count; | let mut count=22; {{ let ref1=&mut count; }} let ref2=&mut count; | Only one mutable borrow. | Rust |
if (data = 83) | if (data == 83) | Use ==. | C++ |
[15, 34, 3 | [15, 34, 3] | Close bracket. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
def bar(c):
return c + 1 | def bar(c):
return c + 1 | Correct. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let y: number | null = null; y.toFixed(93); | let y: number | null = null; if(y!==null) y.toFixed(93); | Null check. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(28); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(28); | Correct. | Node.js |
[39, 55, 73 | [39, 55, 73] | Close bracket. | Ruby |
if y = 45 then
print('info')
end | if y == 45 then
print('info')
end | Use ==. | Lua |
items[22] | if (length(items) >= 22) items[22] | Check length. | R |
$index = 26; if ($index = 26) {{}} | $index = 26; if ($index == 26) {{}} | Use ==. | PHP |
[x*x for x in arr if x > 55] | [x*x for x in arr if x > 55] | Correct list comprehension. | Python |
'value' + 37 | 'value' + str(37) | Can't add int to string. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
h1 {{ font-size:26px color:#fff; }} | h1 {{ font-size:26px; color:#fff; }} | Add semicolon. | CSS |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
SELECT * FROM products WHRE age=81; | SELECT * FROM products WHERE age=81; | Fix WHERE. | SQL |
println('result') | println("result") | Double quotes. | Scala |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<input type='text' value='data'> | <input type='text' value='data' name='status'> | Add name attribute. | HTML |
let item = 58; let item = 47; | let item = 58; item = 47; | Duplicate declaration. | JavaScript |
DELETE FROM products WHERE email=56 | DELETE FROM products WHERE email=56; | Add semicolon. | SQL |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
arr[90] | if arr.indices.contains(90) {{ arr[90] }} | Check index. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.