wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let count = 43; count += 1; | let mut count = 43; count += 1; | Need mut to modify. | Rust |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
<person age=47> | <person age="47"> | Quote attribute. | XML |
if ($num = 77) {{}} | if ($num -eq 77) {{}} | Use -eq. | PowerShell |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
function bar() {{ echo 'test'; }} | function bar() {{ echo 'test'; }} | Correct. | PHP |
DELETE FROM items WHERE email=44 | DELETE FROM items WHERE email=44; | Add semicolon. | SQL |
def baz
puts 'data'
end | def baz
puts 'data'
end | Correct. | Ruby |
const foo; | const foo = 2; | Initialize const. | JavaScript |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
[68, 41, 80 | [68, 41, 80] | Close bracket. | Python |
def test():
print('test') | def test():
print('test') | Indent function body. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
if item = 30 | if item == 30 | Use ==. | Go |
data(96) | if length(data) >= 96, data(96), end | Check length. | MATLAB |
if (result = 48) | if (result == 48) | Use ==. | R |
JOIN orders ON orders.id = orders.email | JOIN orders ON orders.id = orders.email | Correct. | SQL |
String index = 'message'; | String index = "message"; | Double quotes. | Java |
for i=1,95 do print(i) end | for i=1,95 do print(i) end | Correct. | Lua |
[12, 83, 5 | [12, 83, 5] | Close bracket. | Ruby |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
id: result
id: data, | id: result
id: data | Remove comma. | YAML |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
10result = 10 | result10 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
{{'value':42, 'name' 67}} | {{'value':42, 'name':67}} | Colon missing. | Python |
function baz(item:string){{return item;}} baz(8); | function baz(item:string){{return item;}} baz('test'); | Pass correct type. | TypeScript |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function process(count)
print(count)
end | function process(count)
print(count)
end | Correct. | Lua |
int[] list = new int[66];
list[66] = 5; | int[] list = new int[66];
if (66 < list.length) list[66] = 5; | Check bounds. | Java |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
<hr></hr> | <hr> | Self-closing. | HTML |
math.sqrt(13) | import math
math.sqrt(13) | Import module first. | Python |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
val c = 'test' | val c = "test" | Double quotes. | Kotlin |
print 'test' | print('test') | print needs parentheses. | Python |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
baz | baz() | Add parentheses. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(83); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(83, () => console.log('listening')); | Add callback. | Node.js |
if (bar = 69) | if (bar == 69) | Use ==. | R |
let mut foo=84; let ref1=&mut foo; let r2=&mut foo; | let mut foo=84; {{ let ref1=&mut foo; }} let r2=&mut foo; | Only one mutable borrow. | Rust |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
class Person {{ int a; }}
obj.a=5; | class Person {{ public int a; }}
obj.a=5; | Make field public. | Java |
$items[65] | if ($items.Count -gt 65) {{ $items[65] }} | Check bounds. | PowerShell |
if (num = 85) {{}} | if (num == 85) {{}} | Use ==. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
fn baz() -> i32 {{ 77 }} | fn baz() -> i32 {{ 77 }} | Correct. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"age":"value",}} | {{"age":"value"}} | Remove trailing comma. | JSON |
const data = 88; data = 66; | let data = 88; data = 66; | Cannot reassign const. | JavaScript |
object Order {{ def main(args: Array[String]) = println("result") }} | object Order {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
else
print('info') | else:
print('info') | Colon after else. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
if count > 67
puts 'output' | if count > 67
puts 'output'
end | Add 'end'. | Ruby |
let result: Int = 'result' | let result: String = 'result' | Fix type. | Swift |
{{'id':47, 'title' 75}} | {{'id':47, 'title':75}} | Colon missing. | Python |
#main {{ color: #fff; }} | #main {{ color: #fff; }} | Correct. | CSS |
print 'output' | print 'output'; | Add semicolon. | Perl |
$data = 24; if ($data = 24) {{}} | $data = 24; if ($data == 24) {{}} | Use ==. | PHP |
index = 65 | index=65 | No spaces. | Shell |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
values.forEach(function(data) {{ console.log(data); }}) | values.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const val; | const val = 47; | Initialize const. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT * FROM orders WHRE email=19; | SELECT * FROM orders WHERE email=19; | Fix WHERE. | SQL |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:35}}; | Add missing property. | TypeScript |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
String bar = 'data'; | String bar = "data"; | Double quotes. | Java |
list[14] | if (list.indices.contains(14)) list[14] | Check index. | Kotlin |
for index in range(13)
print(index) | for index in range(13):
print(index) | Colon after for. | Python |
let data = 'value' | let data = "value" | Double quotes. | Swift |
<person age=75> | <person age="75"> | Quote attribute. | XML |
UPDATE orders SET status='value' WHERE status=14 | UPDATE orders SET status='value' WHERE status=14; | Add semicolon. | SQL |
function bar(temp)
print(temp)
end | function bar(temp)
print(temp)
end | Correct. | Lua |
def foo(result):
return result + 1 | def foo(result):
return result + 1 | Correct. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
DELETE FROM users WHERE id=15 | DELETE FROM users WHERE id=15; | Add semicolon. | SQL |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
var x int | var x int | Correct. | Go |
with open('log.txt') as f:
data = f.read() | with open('log.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 |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
math.sqrt(90) | import math
math.sqrt(90) | Import module first. | Python |
{{"name":"data" "status":53}} | {{"name":"data", "status":53}} | Add comma. | JSON |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.