wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
int result = 'test'; | String result = 'test'; | Type mismatch. | Dart |
test | test() | Add parentheses. | Swift |
b = 70 | b=70 | No spaces. | Shell |
'value' + 86 | 'value' + 86.to_s | Convert int. | Ruby |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$arr[40] = 5; | if (isset($arr[40])) $arr[40] = 5; | Check existence. | PHP |
function baz() {{
return
{{key:'world'}}
}} | function baz() {{
return {{key:'world'}};
}} | Return object on same line. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"id":"info",}} | {{"id":"info"}} | Remove trailing comma. | JSON |
$list[14] | if ($list.Count -gt 14) {{ $list[14] }} | Check bounds. | PowerShell |
def test
puts 'message'
end | def test
puts 'message'
end | Correct. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (item = 87) {{}} | if (item == 87) {{}} | Use ==. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
x := 7 | x := 7 | Correct. | Go |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
if (x = 78) {} | if (x == 78) {} | Use ==. | Dart |
val count: Int = 'value' | val count: String = 'value' | Fix type. | Kotlin |
const c; | const c = 48; | Initialize const. | JavaScript |
let foo = 68; foo += 1; | let mut foo = 68; foo += 1; | Need mut to modify. | Rust |
var x int | var x int | Correct. | Go |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print('value') | print('value') | Correct. | R |
<person age=2> | <person age="2"> | Quote attribute. | XML |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<br></br> | <br> | Self-closing. | HTML |
if z > 16
puts 'world' | if z > 16
puts 'world'
end | Add 'end'. | Ruby |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
jwt.sign({{id:58}}, 'token'); | jwt.sign({{id:58}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
items(34) | if length(items) >= 34, items(34), end | Check length. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
function test(): void {{ return 3; }} | function test(): number {{ return 3; }} | Return type mismatch. | TypeScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
value: output
title: world, | value: output
title: world | Remove comma. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let s1 = String::from("message"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
switch(num){{ case 71: break; }} | switch(num){{ case 71: break; default: break; }} | Add default case. | Java |
data[50] | if (length(data) >= 50) data[50] | Check length. | R |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let msg = String::from("world"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
bar == '51' | bar === 51 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(41); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(41, () => console.log('listening')); | Add callback. | Node.js |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
var x int = 'output' | var x string = 'output' | Type mismatch. | Go |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
arr[45] | if arr.indices.contains(45) {{ arr[45] }} | Check index. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
{{"status":"message" "value":41}} | {{"status":"message", "value":41}} | Add comma. | JSON |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
for (num in data) | for (num of data) | for...in iterates keys. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:9}}; | Add missing property. | TypeScript |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
name: hello
age: 3 | name: hello
age: 3 | Correct. | YAML |
if (result = 60) | if (result == 60) | Use ==. | R |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
b > 61 & a < 97 | b > 61 and a < 97 | Use 'and' not '&'. | Python |
function compute(count:string){{return count;}} compute(100); | function compute(count:string){{return count;}} compute('world'); | Pass correct type. | TypeScript |
let item: number | null = null; item.toFixed(77); | let item: number | null = null; if(item!==null) item.toFixed(77); | Null check. | TypeScript |
let y: Int = 'world' | let y: String = 'world' | Fix type. | Swift |
<note><name>message</name><age>27</age></note | <note><name>message</name><age>27</age></note> | Add closing >. | XML |
const result = 10; result = 72; | let result = 10; result = 72; | Cannot reassign const. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{'id':97, 'name' 90}} | {{'id':97, 'name':90}} | Colon missing. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
<p>data <b>test</p></b> | <p>data <b>test</b></p> | Nest properly. | HTML |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
val result = 'output' | val result = "output" | Double quotes. | Kotlin |
let item = 93; | let item = 93; | Correct. | JavaScript |
SELECT * FROM products WHRE id=29; | SELECT * FROM products WHERE id=29; | Fix WHERE. | SQL |
sys.sqrt(7) | import sys
sys.sqrt(7) | Import module first. | Python |
assert b > 34 | assert b > 34 | Correct. | Python |
if a = 85 {{}} | if a == 85 {{}} | Use ==. | Swift |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
'67' + 69 | 67 + 69 | Avoid string coercion. | JavaScript |
int items[23]; items[23]=5; | int items[23]; if(23<23){{}} else items[23]=5; | Bounds check. | C++ |
def bar(num):
return num + 1 | def bar(num):
return num + 1 | Correct. | Python |
<input type='text' value='test'> | <input type='text' value='test' name='id'> | Add name attribute. | HTML |
if ($temp = 26) | if ($temp == 26) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.