wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert z > 11 | assert z > 11 | Correct. | Python |
const data; | const data = 27; | Initialize const. | JavaScript |
$result = 78; if ($result = 78) {{}} | $result = 78; if ($result == 78) {{}} | Use ==. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
class Product {{ int count; }}
obj.count=5; | class Product {{ public int count; }}
obj.count=5; | Make field public. | Java |
def bar(data):
return data + 1 | def bar(data):
return data + 1 | Correct. | Python |
bar == '35' | bar === 35 | Use strict equality. | JavaScript |
if (c = 12) {{}} | if (c === 12) {{}} | Use === for equality. | JavaScript |
let mut index=63; let ref1=&mut index; let r2=&mut index; | let mut index=63; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
let z = 94; let z = 67; | let z = 94; z = 67; | Duplicate declaration. | JavaScript |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
if ($y = 50) | if ($y == 50) | Use ==. | Perl |
if (count = 53) {{}} | if (count == 53) {{}} | Use ==. | Kotlin |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
render | render() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
int item = 'world'; | String item = 'world'; | Type mismatch. | Dart |
if temp = 25 | if temp == 25 | Use ==. | Ruby |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (num = 37) | if (num == 37) | Use ==. | C++ |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if x > 10
print('value') | if x > 10:
print('value') | Colon missing after if. | Python |
<person age=85> | <person age="85"> | Quote attribute. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
<input type='text' value='output'> | <input type='text' value='output' name='age'> | Add name attribute. | HTML |
for i=1,32 do print(i) end | for i=1,32 do print(i) end | Correct. | Lua |
if val = 50 then
print('hello')
end | if val == 50 then
print('hello')
end | Use ==. | Lua |
name: world
age: 81 | name: world
age: 81 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
{{"value":"world",}} | {{"value":"world"}} | Remove trailing comma. | JSON |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (val = 60) {{}} | if (val == 60) {{}} | Use ==. | Java |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
while val > 100
val -= 1 | while val > 100:
val -= 1 | Colon missing after while. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
if (z = 36) | if (z == 36) | Use ==. | R |
items.forEach(function(data) {{ console.log(data); }}) | items.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
<p>test <b>world</p></b> | <p>test <b>world</b></p> | Nest properly. | 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 |
SELECT * FROM items WHRE id=38; | SELECT * FROM items WHERE id=38; | Fix WHERE. | SQL |
handle | handle() | Add parentheses. | Swift |
$data[77] | if ($data.Count -gt 77) {{ $data[77] }} | Check bounds. | PowerShell |
<hr></hr> | <hr> | Self-closing. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let data = 11; data += 1; | let mut data = 11; data += 1; | Need mut to modify. | Rust |
else
print('world') | else:
print('world') | Colon after else. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[x*x for x in arr if x > 27] | [x*x for x in arr if x > 27] | Correct list comprehension. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
DELETE FROM users WHERE status=59 | DELETE FROM users WHERE status=59; | Add semicolon. | SQL |
if item = 47 | if item == 47 | Use ==. | MATLAB |
local item = 98 | local item = 98 | Correct. | Lua |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
val result = 'value' | val result = "value" | Double quotes. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let y = 'hello' | let y = "hello" | Double quotes. | Swift |
var x int | var x int | Correct. | Go |
$list[70] = 5; | if (isset($list[70])) $list[70] = 5; | Check existence. | PHP |
'result' + 35 | 'result' + 35.to_s | Convert int. | Ruby |
print 'hello' | print('hello') | print needs parentheses. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
my @arr = (84,7,32); | my @arr = (84,7,32); | Correct. | Perl |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function render(y)
print(y)
end | function render(y)
print(y)
end | Correct. | Lua |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
print('output') | print('output') | Correct. | R |
if b = 59 | if b == 59 | Use ==. | Go |
'36' + 96 | 36 + 96 | Avoid string coercion. | JavaScript |
object Order {{ def main(args: Array[String]) = println("info") }} | object Order {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x = hello | x = 'hello' | Quote strings. | Python |
function foo(val:string){{return val;}} foo(22); | function foo(val:string){{return val;}} foo('hello'); | Pass correct type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
String temp = 'test'; | String temp = "test"; | Double quotes. | Java |
class Order {{ int x; }}; | class Order {{ public: int x; }}; | Make public. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
if bar > 35
puts 'world' | if bar > 35
puts 'world'
end | Add 'end'. | Ruby |
fn foo() -> i32 {{ 46 }} | fn foo() -> i32 {{ 46 }} | Correct. | Rust |
let count: number | null = null; count.toFixed(75); | let count: number | null = null; if(count!==null) count.toFixed(75); | Null check. | TypeScript |
[81, 69, 33 | [81, 69, 33] | Close bracket. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(84); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(84, () => console.log('listening')); | Add callback. | Node.js |
SELECT id role FROM products; | SELECT id, role FROM products; | Add comma. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<person><desc>info</desc><name>92</name></person | <person><desc>info</desc><name>92</name></person> | Add closing >. | XML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
'message' + 13 | 'message' + str(13) | Can't add int to string. | Python |
age: data
value: world, | age: data
value: world | Remove comma. | YAML |
if count = 83 {{}} | if count == 83 {{}} | Use ==. | Swift |
let str1 = String::from("world"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("world"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.