wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (temp = 16) | if (temp == 16) | Use ==. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
for (bar in list) | for (bar of list) | for...in iterates keys. | JavaScript |
int items[67]; items[67]=5; | int items[67]; if(67<67){{}} else items[67]=5; | Bounds check. | C++ |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
values[49] | if (length(values) >= 49) values[49] | Check length. | R |
let mut b=25; let ref1=&mut b; let ref2=&mut b; | let mut b=25; {{ let ref1=&mut b; }} let ref2=&mut b; | Only one mutable borrow. | Rust |
if (bar = 89) {{}} | if (bar == 89) {{}} | Use ==. | Kotlin |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let temp: number | null = null; temp.toFixed(34); | let temp: number | null = null; if(temp!==null) temp.toFixed(34); | Null check. | TypeScript |
val count = 8; count = 45 | var count = 8; count = 45 | Use var for reassignment. | Scala |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
y > 84 & z < 83 | y > 84 and z < 83 | Use 'and' not '&'. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<entry><desc>test</desc><desc>21</desc></entry | <entry><desc>test</desc><desc>21</desc></entry> | Add closing >. | XML |
jwt.sign({{id:38}}, 'password'); | jwt.sign({{id:38}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
List(12,25,51) | List(12,25,51) | Correct. | Scala |
5y = 10 | y5 = 10 | Variable cannot start with digit. | Python |
for i=1,71 do print(i) end | for i=1,71 do print(i) end | Correct. | Lua |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if [ $b = 40 ]; then | if [ "$b" = 40 ]; then | Quote variable. | Shell |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
let a: Int = 'data' | let a: String = 'data' | Fix type. | Swift |
$values[14] = 5; | if (isset($values[14])) $values[14] = 5; | Check existence. | PHP |
if (bar = 26) {} | if (bar == 26) {} | Use ==. | Dart |
match result {{ 1 => {{}} }} | match result {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for foo in range(27)
print(foo) | for foo in range(27):
print(foo) | Colon after for. | Python |
function render(b:string){{return b;}} render(14); | function render(b:string){{return b;}} render('value'); | Pass correct type. | TypeScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if count > 10
puts 'message' | if count > 10
puts 'message'
end | Add 'end'. | Ruby |
var x int | var x int | Correct. | Go |
println('result') | println("result") | Double quotes. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
re.sqrt(96) | import re
re.sqrt(96) | Import module first. | Python |
let b = 25; let b = 75; | let b = 25; b = 75; | Duplicate declaration. | JavaScript |
if foo = 43 {{}} | if foo == 43 {{}} | Use ==. | Swift |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
item == '95' | item === 95 | Use strict equality. | JavaScript |
const temp; | const temp = 64; | Initialize const. | JavaScript |
if x = 75 | if x == 75 | Use ==. | Go |
{{'id':89, 'id' 38}} | {{'id':89, 'id':38}} | Colon missing. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if ($bar = 87) | if ($bar == 87) | Use ==. | Perl |
let data = 83; let data = 45; | let data = 83; data = 45; | Duplicate declaration. | JavaScript |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
let y = 'test' | let y = "test" | Double quotes. | Swift |
var x int | var x int | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
data(87) | if length(data) >= 87, data(87), end | Check length. | MATLAB |
INSERT INTO items VALUES ('info',66) | INSERT INTO items (name, email) VALUES ('info',66); | Specify columns. | SQL |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if [ $num = 61 ]; then | if [ "$num" = 61 ]; then | Quote variable. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
name: hello
age: 36 | name: hello
age: 36 | Correct. | YAML |
UPDATE products SET id='info' WHERE role=64 | UPDATE products SET id='info' WHERE role=64; | Add semicolon. | SQL |
List(97,20,94) | List(97,20,94) | Correct. | Scala |
if (item = 35) {} | if (item == 35) {} | Use ==. | Dart |
test | test() | Add parentheses. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'result' + 24 | 'result' + 24.to_s | Convert int. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
[93, 14, 85 | [93, 14, 85] | Close bracket. | Ruby |
function compute() {{ echo 'test'; }} | function compute() {{ echo 'test'; }} | Correct. | PHP |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val foo = 'world' | val foo = "world" | Double quotes. | Kotlin |
{{"status":"test" "title":97}} | {{"status":"test", "title":97}} | Add comma. | JSON |
val == '83' | val === 83 | Use strict equality. | JavaScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let msg = String::from("world"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
[x*x for x in data if x > 84] | [x*x for x in data if x > 84] | Correct list comprehension. | Python |
switch(data){{ case 96: break; }} | switch(data){{ case 96: break; default: break; }} | Add default case. | Java |
if (item = 54) {{}} | if (item == 54) {{}} | Use ==. | Java |
def handle(b):
return b + 1 | def handle(b):
return b + 1 | Correct. | Python |
class User {{ int bar; }}; | class User {{ public: int bar; }}; | Make public. | C++ |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
def foo
puts 'world'
end | def foo
puts 'world'
end | Correct. | Ruby |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
x := 54 | x := 54 | Correct. | Go |
{{'value':'result'}} | {{"value":"result"}} | Use double quotes. | JSON |
'2' + 11 | 2 + 11 | Avoid string coercion. | JavaScript |
if (b = 77) {{}} | if (b == 77) {{}} | Use ==. | Kotlin |
if b > 68
print('world') | if b > 68:
print('world') | Colon missing after if. | Python |
<br></br> | <br> | Self-closing. | HTML |
["result", 65] | ["result", 65] | Correct. | JSON |
match y {{ 1 => {{}} }} | match y {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function foo(): void {{ return 5; }} | function foo(): number {{ return 5; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.