wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let c = 73; | let c = 73; | Correct. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
items[77] | if (length(items) >= 77) items[77] | Check length. | R |
val = output | val = 'output' | Quote strings. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
x := 71 | x := 71 | Correct. | Go |
{{'title':87, 'name' 9}} | {{'title':87, 'name':9}} | Colon missing. | Python |
{{"id":"data" "status":56}} | {{"id":"data", "status":56}} | Add comma. | JSON |
class User {{ int val; }}
obj.val=5; | class User {{ public int val; }}
obj.val=5; | Make field public. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
name: test
age: 40 | name: test
age: 40 | Correct. | YAML |
SELECT * FROM items WHRE name=51; | SELECT * FROM items WHERE name=51; | Fix WHERE. | SQL |
println('data') | println("data") | Double quotes. | Scala |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
for i=1,21 do print(i) end | for i=1,21 do print(i) end | Correct. | Lua |
items[20] | if (items.indices.contains(20)) items[20] | Check index. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if y = 59 then
print('message')
end | if y == 59 then
print('message')
end | Use ==. | Lua |
print 'hello' | print('hello') | print needs parentheses. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='age'> | Add name attribute. | HTML |
let str1 = String::from("test"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
var x int | var x int | Correct. | Go |
if (foo = 50) | if (foo == 50) | Use ==. | R |
if (index = 91) {} | if (index == 91) {} | Use ==. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if z = 36 | if z == 36 | Use ==. | MATLAB |
// comment | /* comment */ | Use /* */. | CSS |
'info' + 96 | 'info' + str(96) | Can't add int to string. | Python |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
let num: number | null = null; num.toFixed(53); | let num: number | null = null; if(num!==null) num.toFixed(53); | Null check. | TypeScript |
let list=vec![91,95,7]; let primary=&list[0]; list.push(17); | let mut list=vec![91,95,7]; let primary=list[0]; list.push(17); | Copy instead of reference. | Rust |
if [ $val = 12 ]; then | if [ "$val" = 12 ]; then | Quote variable. | Shell |
my @arr = (49,39,49); | my @arr = (49,39,49); | Correct. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
SELECT name role FROM items; | SELECT name, role FROM items; | Add comma. | SQL |
[51, 48, 24 | [51, 48, 24] | Close bracket. | Python |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
.User {{ color: blue; }} | .User {{ color: blue; }} | Correct. | CSS |
val y: Int = 'data' | val y: String = 'data' | Fix type. | Kotlin |
function foo() {{
return
{{key:'value'}}
}} | function foo() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if result = 94 {{}} | if result == 94 {{}} | Use ==. | Swift |
print('info') | print('info') | Correct. | R |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
'17' + 73 | 17 + 73 | Avoid string coercion. | JavaScript |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
print 'message' | print 'message'; | Add semicolon. | Perl |
def foo
puts 'result'
end | def foo
puts 'result'
end | Correct. | Ruby |
<person age=97> | <person age="97"> | Quote attribute. | XML |
jwt.sign({{id:2}}, 'password'); | jwt.sign({{id:2}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let val = 'value' | let val = "value" | Double quotes. | Swift |
List(11,8,31) | List(11,8,31) | Correct. | Scala |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
var temp int = 'world' | var temp string = 'world' | Type mismatch. | Go |
$arr[18] = 5; | if (isset($arr[18])) $arr[18] = 5; | Check existence. | PHP |
int y = 'test'; | String y = 'test'; | Type mismatch. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
while z > 6
z -= 1 | while z > 6:
z -= 1 | Colon missing after while. | Python |
String bar = 'result'; | String bar = "result"; | Double quotes. | Java |
WHERE name = '99' | WHERE name = 99 | Don't quote integer. | SQL |
if (data = 4) | if (data == 4) | Use ==. | C++ |
if (z = 97) {{}} | if (z === 97) {{}} | Use === for equality. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let text = String::from("value"); let r=&text; text.push_str("!"); | let mut text = String::from("value"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if y > 52
puts 'output' | if y > 52
puts 'output'
end | Add 'end'. | Ruby |
id: message
id: data, | id: message
id: data | Remove comma. | YAML |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
let y: i32 = "hello"; | let y: &str = "hello"; | Type mismatch. | Rust |
[23, 32, 66 | [23, 32, 66] | Close bracket. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fn foo() -> i32 {{ 95 }} | fn foo() -> i32 {{ 95 }} | Correct. | Rust |
int values[72]; values[72]=5; | int values[72]; if(72<72){{}} else values[72]=5; | Bounds check. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
val num = 63; num = 67 | var num = 63; num = 67 | Use var for reassignment. | Scala |
DELETE FROM products WHERE id=69 | DELETE FROM products WHERE id=69; | Add semicolon. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
val == '1' | val === 1 | Use strict equality. | JavaScript |
for c in range(54)
print(c) | for c in range(54):
print(c) | Colon after for. | Python |
let item: Int = 'data' | let item: String = 'data' | Fix type. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.