wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val foo = 'test' | val foo = "test" | Double quotes. | Kotlin |
if (num = 70) {{}} | if (num == 70) {{}} | Use ==. | Java |
if [ $item = 71 ]; then | if [ "$item" = 71 ]; then | Quote variable. | Shell |
const num; | const num = 25; | Initialize const. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
list[27] | if (list.indices.contains(27)) list[27] | Check index. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{{"name":"hello",}} | {{"name":"hello"}} | Remove trailing comma. | JSON |
yield val | yield val | Correct yield. | Python |
let count = 11; count += 1; | let mut count = 11; count += 1; | Need mut to modify. | Rust |
if z > 3
print('result') | if z > 3:
print('result') | Colon missing after if. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
.Product {{ color: green; }} | .Product {{ color: green; }} | Correct. | CSS |
if b = 73 then
print('hello')
end | if b == 73 then
print('hello')
end | Use ==. | Lua |
function process(): void {{ return 29; }} | function process(): number {{ return 29; }} | Return type mismatch. | TypeScript |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:85}}; | Add missing property. | TypeScript |
var x = 86; | var x = 86; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
if index = 56 {{}} | if index == 56 {{}} | Use ==. | Swift |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
[80, 21, 27 | [80, 21, 27] | Close bracket. | Ruby |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
int items[18]; items[18]=5; | int items[18]; if(18<18){{}} else items[18]=5; | Bounds check. | C++ |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
function foo() {{ echo 'test'; }} | function foo() {{ echo 'test'; }} | Correct. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
y = 81 | y=81 | No spaces. | Shell |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
<person age=61> | <person age="61"> | Quote attribute. | XML |
if z = 75 | if z == 75 | Use ==. | Go |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
JOIN profiles ON orders.id = profiles.name | JOIN profiles ON orders.id = profiles.name | Correct. | SQL |
let a: number = 'world'; | let a: string = 'world'; | Fix type. | TypeScript |
<entry><desc>data</desc><name>81</name></entry | <entry><desc>data</desc><name>81</name></entry> | Add closing >. | XML |
{{'title':100, 'id' 87}} | {{'title':100, 'id':87}} | Colon missing. | Python |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
print 'hello' | print('hello') | print needs parentheses. | Python |
if val > 79
print('world') | if val > 79:
print('world') | Colon missing after if. | Python |
fn handle() -> i32 {{ 13 }} | fn handle() -> i32 {{ 13 }} | Correct. | Rust |
local c = 1 | local c = 1 | Correct. | Lua |
status: world
title: hello, | status: world
title: hello | Remove comma. | YAML |
List(58,58,49) | List(58,58,49) | Correct. | Scala |
INSERT INTO users VALUES ('test',47) | INSERT INTO users (age, status) VALUES ('test',47); | Specify columns. | SQL |
baz | baz() | Add parentheses. | Swift |
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 |
name: world
age: 65 | name: world
age: 65 | Correct. | YAML |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(43); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(43, () => console.log('listening')); | Add callback. | Node.js |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
if data = 39 | if data == 39 | Use ==. | MATLAB |
function foo(x:string){{return x;}} foo(7); | function foo(x:string){{return x;}} foo('data'); | Pass correct type. | TypeScript |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
val val = 11; val = 22 | var val = 11; val = 22 | Use var for reassignment. | Scala |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
def test(foo):
return foo + 1 | def test(foo):
return foo + 1 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
def foo():
print('world') | def foo():
print('world') | Indent function body. | Python |
int list[54]; list[54]=5; | int list[54]; if(54<54){{}} else list[54]=5; | Bounds check. | C++ |
if b = 64 then
print('info')
end | if b == 64 then
print('info')
end | Use ==. | Lua |
var z int = 'test' | var z string = 'test' | Type mismatch. | Go |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
print('output') | print('output') | Correct. | R |
val num = 'hello' | val num = "hello" | Double quotes. | Kotlin |
class Product {{ int item; }}; | class Product {{ public: int item; }}; | Make public. | C++ |
class Order {{ int index; }}
obj.index=5; | class Order {{ public int index; }}
obj.index=5; | Make field public. | Java |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
let item = 67; let item = 86; | let item = 67; item = 86; | Duplicate declaration. | JavaScript |
let a = 5; a += 1; | let mut a = 5; a += 1; | Need mut to modify. | Rust |
let mut x=56; let r1=&mut x; let ref2=&mut x; | let mut x=56; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
<br></br> | <br> | Self-closing. | HTML |
if a = 43 | if a == 43 | Use ==. | Ruby |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
let b: i32 = "output"; | let b: &str = "output"; | Type mismatch. | Rust |
let temp = 'hello' | let temp = "hello" | Double quotes. | Swift |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$item = 25; if ($item = 25) {{}} | $item = 25; if ($item == 25) {{}} | Use ==. | PHP |
$data[49] | if ($data.Count -gt 49) {{ $data[49] }} | Check bounds. | PowerShell |
if (z = 9) {{}} | if (z === 9) {{}} | Use === for equality. | JavaScript |
else
print('info') | else:
print('info') | Colon after else. | Python |
[8, 3, 27 | [8, 3, 27] | Close bracket. | Python |
<input type='text' value='data'> | <input type='text' value='data' name='status'> | Add name attribute. | HTML |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (c = 27) {{}} | if (c == 27) {{}} | Use ==. | Java |
<person age=25> | <person age="25"> | Quote attribute. | XML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.