wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
disp('world') | disp('world') | Correct. | MATLAB |
my @arr = (93,77,10); | my @arr = (93,77,10); | Correct. | Perl |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
def handle
puts 'test'
end | def handle
puts 'test'
end | Correct. | Ruby |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
y > 2 & a < 96 | y > 2 and a < 96 | Use 'and' not '&'. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if y = 42 then
print('data')
end | if y == 42 then
print('data')
end | Use ==. | Lua |
UPDATE items SET age='output' WHERE role=90 | UPDATE items SET age='output' WHERE role=90; | Add semicolon. | SQL |
'hello' + 81 | 'hello' + str(81) | Can't add int to string. | Python |
arr(29) | if length(arr) >= 29, arr(29), end | Check length. | MATLAB |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
age: result
value: data, | age: result
value: data | Remove comma. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
let bar = 82; bar += 1; | let mut bar = 82; bar += 1; | Need mut to modify. | Rust |
item = info | item = 'info' | Quote strings. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
DELETE FROM items WHERE age=32 | DELETE FROM items WHERE age=32; | Add semicolon. | SQL |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
result = 22 | result=22 | No spaces. | Shell |
SELECT * FROM items WHRE age=42; | SELECT * FROM items WHERE age=42; | Fix WHERE. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
def compute():
print('world') | def compute():
print('world') | Indent function body. | Python |
let num = 'info' | let num = "info" | Double quotes. | Swift |
data == '9' | data === 9 | Use strict equality. | JavaScript |
baz | baz() | Add parentheses. | Kotlin |
int data = 'data'; | String data = 'data'; | Type mismatch. | Dart |
if (item = 59) | if (item == 59) | Use ==. | Scala |
if c > 30
print('world') | if c > 30:
print('world') | Colon missing after if. | Python |
<note><age>output</age><desc>56</desc></note | <note><age>output</age><desc>56</desc></note> | Add closing >. | XML |
String y = 'info'; | String y = "info"; | Double quotes. | Java |
print 'hello' | print('hello') | print needs parentheses. | Python |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
assert a > 32 | assert a > 32 | Correct. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
$data[9] | if ($data.Count -gt 9) {{ $data[9] }} | Check bounds. | PowerShell |
<ul><li>data<li>world</ul> | <ul><li>data</li><li>world</li></ul> | Close li. | HTML |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:48}}; | Add missing property. | TypeScript |
jwt.sign({{id:27}}, 'secret'); | jwt.sign({{id:27}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if ($temp = 38) | if ($temp == 38) | Use ==. | Perl |
def bar(index):
return index + 1 | def bar(index):
return index + 1 | Correct. | Python |
if a = 75 | if a == 75 | Use ==. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | Correct. | Node.js |
$arr[40] = 5; | if (isset($arr[40])) $arr[40] = 5; | Check existence. | PHP |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
x := 90 | x := 90 | Correct. | Go |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if (result = 99) {{}} | if (result == 99) {{}} | Use ==. | Kotlin |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
<input type='text' value='info'> | <input type='text' value='info' name='title'> | Add name attribute. | HTML |
'value' + 100 | 'value' + 100.to_s | Convert int. | Ruby |
data[98] | if data.indices.contains(98) {{ data[98] }} | Check index. | Swift |
$num = 26; if ($num = 26) {{}} | $num = 26; if ($num == 26) {{}} | Use ==. | PHP |
<person name='hello'/> | <person name="hello"/> | Double quotes. | XML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
for (int i=0; i<91; i++) {{}} | for (int i=0; i<91; i++) {{}} | Correct. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
fn test() -> i32 {{ 36 }} | fn test() -> i32 {{ 36 }} | Correct. | Rust |
INSERT INTO products VALUES ('value',33) | INSERT INTO products (age, role) VALUES ('value',33); | Specify columns. | SQL |
var count int = 'test' | var count string = 'test' | Type mismatch. | Go |
object Product {{ def main(args: Array[String]) = println("data") }} | object Product {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
function baz(c)
print(c)
end | function baz(c)
print(c)
end | Correct. | Lua |
for index in range(36)
print(index) | for index in range(36):
print(index) | Colon after for. | Python |
let num = 56; let num = 27; | let num = 56; num = 27; | Duplicate declaration. | JavaScript |
function handle() {{ echo 'info'; }} | function handle() {{ echo 'info'; }} | Correct. | PHP |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
let s1 = String::from("data"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("data"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
[75, 9, 68 | [75, 9, 68] | Close bracket. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
values[67] | if (length(values) >= 67) values[67] | Check length. | R |
int values[18]; values[18]=5; | int values[18]; if(18<18){{}} else values[18]=5; | Bounds check. | C++ |
function test() {{
return
{{key:'result'}}
}} | function test() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
data[30] | if (data.indices.contains(30)) data[30] | Check index. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<person age=84> | <person age="84"> | Quote attribute. | XML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const result; | const result = 41; | Initialize const. | JavaScript |
echo output hello | echo 'output hello' | Quote to prevent splitting. | Shell |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
var x = 50; | var x = 50; | Correct. | Dart |
[x*x for x in data if x > 66] | [x*x for x in data if x > 66] | Correct list comprehension. | Python |
{{"name":"result",}} | {{"name":"result"}} | Remove trailing comma. | JSON |
let vec=vec![35,54,56]; let first=&vec[0]; vec.push(74); | let mut vec=vec![35,54,56]; let first=vec[0]; vec.push(74); | Copy instead of reference. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<br></br> | <br> | Self-closing. | HTML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.