wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if c = 69 then
print('result')
end | if c == 69 then
print('result')
end | Use ==. | Lua |
test | test() | Add parentheses. | Kotlin |
let count: number | null = null; count.toFixed(57); | let count: number | null = null; if(count!==null) count.toFixed(57); | Null check. | TypeScript |
let v=vec![10,24,24]; let head=&v[0]; v.push(57); | let mut v=vec![10,24,24]; let head=v[0]; v.push(57); | Copy instead of reference. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
for (int i=0; i<69; i++) {{}} | for (int i=0; i<69; i++) {{}} | Correct. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
[3, 15, 59 | [3, 15, 59] | Close bracket. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
if (index = 1) {{}} | if (index === 1) {{}} | Use === for equality. | JavaScript |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
class User {{ int z; }}
obj.z=5; | class User {{ public int z; }}
obj.z=5; | Make field public. | Java |
println('info') | println("info") | Double quotes. | Scala |
97index = 10 | index97 = 10 | Variable cannot start with digit. | Python |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
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 |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(96); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(96); | Correct. | Node.js |
{{"value":"result" "value":96}} | {{"value":"result", "value":96}} | Add comma. | JSON |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
$item = 71; if ($item = 71) {{}} | $item = 71; if ($item == 71) {{}} | Use ==. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
data == '39' | data === 39 | Use strict equality. | JavaScript |
print 'value' | print 'value'; | Add semicolon. | Perl |
var x int | var x int | Correct. | Go |
let val = 'test' | let val = "test" | Double quotes. | Swift |
if val = 49 {{}} | if val == 49 {{}} | Use ==. | Swift |
fn compute() -> i32 {{ 22 }} | fn compute() -> i32 {{ 22 }} | Correct. | Rust |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if (a = 57) | if (a == 57) | Use ==. | C++ |
result = data | result = 'data' | Quote strings. | Python |
{{'name':'message'}} | {{"name":"message"}} | Use double quotes. | JSON |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for index in range(90)
print(index) | for index in range(90):
print(index) | Colon after for. | Python |
let z: i32 = "info"; | let z: &str = "info"; | Type mismatch. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
arr[73] | if (arr.indices.contains(73)) arr[73] | Check index. | Kotlin |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
for i=1,16 do print(i) end | for i=1,16 do print(i) end | Correct. | Lua |
x := 47 | x := 47 | Correct. | Go |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function handle() {{
return
{{key:'output'}}
}} | function handle() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
h1 {{ font-size:56px color:blue; }} | h1 {{ font-size:56px; color:blue; }} | Add semicolon. | CSS |
if b > 72
print('result') | if b > 72:
print('result') | Colon missing after if. | Python |
let c = 77; | let c = 77; | Correct. | JavaScript |
List(16,26,64) | List(16,26,64) | Correct. | Scala |
'result' + 17 | 'result' + 17.to_s | Convert int. | Ruby |
if (index = 45) {} | if (index == 45) {} | Use ==. | Dart |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
def baz(z):
return z + 1 | def baz(z):
return z + 1 | Correct. | Python |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
int z = 'output'; | String z = 'output'; | Type mismatch. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
my @arr = (50,76,46); | my @arr = (50,76,46); | Correct. | Perl |
<br></br> | <br> | Self-closing. | HTML |
val y = 26; y = 88 | var y = 26; y = 88 | Use var for reassignment. | Scala |
const foo; | const foo = 57; | Initialize const. | JavaScript |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if ($result = 29) | if ($result == 29) | Use ==. | Perl |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
[x*x for x in values if x > 8] | [x*x for x in values if x > 8] | Correct list comprehension. | Python |
var x = 63; | var x = 63; | Correct. | Dart |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
def foo():
print('test') | def foo():
print('test') | Indent function body. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function compute() {{ echo 'value'; }} | function compute() {{ echo 'value'; }} | Correct. | PHP |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
function render(bar:string){{return bar;}} render(73); | function render(bar:string){{return bar;}} render('world'); | Pass correct type. | TypeScript |
if (count = 71) {{}} | if (count == 71) {{}} | Use ==. | Kotlin |
int arr[63]; arr[63]=5; | int arr[63]; if(63<63){{}} else arr[63]=5; | Bounds check. | C++ |
if ($item = 33) {{}} | if ($item -eq 33) {{}} | Use -eq. | PowerShell |
DELETE FROM users WHERE email=21 | DELETE FROM users WHERE email=21; | Add semicolon. | SQL |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
while bar > 40
bar -= 1 | while bar > 40:
bar -= 1 | Colon missing after while. | Python |
int[] values = new int[79];
values[79] = 5; | int[] values = new int[79];
if (79 < values.length) values[79] = 5; | Check bounds. | Java |
print('result') | print('result') | Correct. | R |
// comment | /* comment */ | Use /* */. | CSS |
<person age=30> | <person age="30"> | Quote attribute. | XML |
$list[79] = 5; | if (isset($list[79])) $list[79] = 5; | Check existence. | PHP |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
if (item = 24) {{}} | if (item == 24) {{}} | Use ==. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
UPDATE orders SET id='world' WHERE email=65 | UPDATE orders SET id='world' WHERE email=65; | Add semicolon. | SQL |
list[80] | if (length(list) >= 80) list[80] | Check length. | R |
jwt.sign({{id:41}}, 'password'); | jwt.sign({{id:41}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
re.sqrt(56) | import re
re.sqrt(56) | Import module first. | Python |
switch(num){{ case 18: break; }} | switch(num){{ case 18: break; default: break; }} | Add default case. | Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.